Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit1c06009

Browse files
asvetlovaeros
andauthored
bpo-34679: Restore instantiation Windows IOCP event loop from non-main thread (#15492)
* Restore running proactor event loop from non-main threadCo-Authored-By: Kyle Stanley <aeros167@gmail.com>
1 parent998cf1f commit1c06009

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

‎Lib/asyncio/proactor_events.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
importsocket
1212
importwarnings
1313
importsignal
14+
importthreading
1415
importcollections
1516

1617
from .importbase_events
@@ -627,7 +628,9 @@ def __init__(self, proactor):
627628
proactor.set_loop(self)
628629
self._make_self_pipe()
629630
self_no=self._csock.fileno()
630-
signal.set_wakeup_fd(self_no)
631+
ifthreading.current_thread()isthreading.main_thread():
632+
# wakeup fd can only be installed to a file descriptor from the main thread
633+
signal.set_wakeup_fd(self_no)
631634

632635
def_make_socket_transport(self,sock,protocol,waiter=None,
633636
extra=None,server=None):

‎Lib/test/test_asyncio/test_windows_events.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ def SIGINT_after_delay():
5959
thread.join()
6060

6161

62+
classProactorMultithreading(test_utils.TestCase):
63+
deftest_run_from_nonmain_thread(self):
64+
finished=False
65+
66+
asyncdefcoro():
67+
awaitasyncio.sleep(0)
68+
69+
deffunc():
70+
nonlocalfinished
71+
loop=asyncio.new_event_loop()
72+
loop.run_until_complete(coro())
73+
finished=True
74+
75+
thread=threading.Thread(target=func)
76+
thread.start()
77+
thread.join()
78+
self.assertTrue(finished)
79+
80+
6281
classProactorTests(test_utils.TestCase):
6382

6483
defsetUp(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restores instantiation of Windows IOCP event loops from the non-main thread.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp