Skip to content

Commit a85af58

Browse files
authored
Merge pull request #28470 from meeseeksmachine/auto-backport-of-pr-28398-on-v3.9.x
Backport PR #28398 on branch v3.9.x (Add GIL Release to flush_events in macosx backend)
2 parents aaeb01e + 29637c5 commit a85af58

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/_macosx.m

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy