summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/proactor_events.py6
-rw-r--r--Lib/test/test_asyncio/test_windows_events.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index 229f56e..830d8ed 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -627,10 +627,9 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
self._accept_futures = {} # socket file descriptor => Future
proactor.set_loop(self)
self._make_self_pipe()
- self_no = self._csock.fileno()
if threading.current_thread() is threading.main_thread():
# wakeup fd can only be installed to a file descriptor from the main thread
- signal.set_wakeup_fd(self_no)
+ signal.set_wakeup_fd(self._csock.fileno())
def _make_socket_transport(self, sock, protocol, waiter=None,
extra=None, server=None):
@@ -676,7 +675,8 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
if self.is_closed():
return
- signal.set_wakeup_fd(-1)
+ if threading.current_thread() is threading.main_thread():
+ signal.set_wakeup_fd(-1)
# Call these methods before closing the event loop (before calling
# BaseEventLoop.close), because they can schedule callbacks with
# call_soon(), which is forbidden when the event loop is closed.
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index 9ed10fc..6b00570 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -69,6 +69,8 @@ class ProactorMultithreading(test_utils.TestCase):
nonlocal finished
loop = asyncio.new_event_loop()
loop.run_until_complete(coro())
+ # close() must not call signal.set_wakeup_fd()
+ loop.close()
finished = True
thread = threading.Thread(target=func)