Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 29637c5

Browse filesBrowse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR #28398: Add GIL Release to flush_events in macosx backend
1 parent e392b59 commit 29637c5
Copy full SHA for 29637c5

File tree

1 file changed

+9
-0
lines changed
Filter options

1 file changed

+9
-0
lines changed

‎src/_macosx.m

Copy file name to clipboardExpand all lines: src/_macosx.m
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ static int wait_for_stdin() {
7777

7878
// continuously run an event loop until the stdin_received flag is set to exit
7979
while (!stdin_received && !stdin_sigint) {
80+
// This loop is similar to the main event loop and flush_events which have
81+
// Py_[BEGIN|END]_ALLOW_THREADS surrounding the loop.
82+
// This should not be necessary here because PyOS_InputHook releases the GIL for us.
8083
while (true) {
8184
NSEvent *event = [NSApp nextEventMatchingMask: NSEventMaskAny
8285
untilDate: [NSDate distantPast]
@@ -380,6 +383,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
380383
// to process, breaking out of the loop when no events remain and
381384
// displaying the canvas if needed.
382385
NSEvent *event;
386+
387+
Py_BEGIN_ALLOW_THREADS
388+
383389
while (true) {
384390
event = [NSApp nextEventMatchingMask: NSEventMaskAny
385391
untilDate: [NSDate distantPast]
@@ -390,6 +396,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
390396
}
391397
[NSApp sendEvent:event];
392398
}
399+
400+
Py_END_ALLOW_THREADS
401+
393402
[self->view displayIfNeeded];
394403
Py_RETURN_NONE;
395404
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.