Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #28398 on branch v3.9.x (Add GIL Release to flush_events in macosx backend) #28470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ static int wait_for_stdin() {

// continuously run an event loop until the stdin_received flag is set to exit
while (!stdin_received && !stdin_sigint) {
// This loop is similar to the main event loop and flush_events which have
// Py_[BEGIN|END]_ALLOW_THREADS surrounding the loop.
// This should not be necessary here because PyOS_InputHook releases the GIL for us.
while (true) {
NSEvent *event = [NSApp nextEventMatchingMask: NSEventMaskAny
untilDate: [NSDate distantPast]
Expand Down Expand Up @@ -380,6 +383,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
// to process, breaking out of the loop when no events remain and
// displaying the canvas if needed.
NSEvent *event;

Py_BEGIN_ALLOW_THREADS

while (true) {
event = [NSApp nextEventMatchingMask: NSEventMaskAny
untilDate: [NSDate distantPast]
Expand All @@ -390,6 +396,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
}
[NSApp sendEvent:event];
}

Py_END_ALLOW_THREADS

[self->view displayIfNeeded];
Py_RETURN_NONE;
}
Expand Down
Loading