summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/proactor_events.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-10-23 15:25:29 (GMT)
committerGitHub <noreply@github.com>2019-10-23 15:25:29 (GMT)
commit1b53a24fb4417c764dd5933bce505f5c94249ca6 (patch)
treebaaa5308734bdaed5f44da7118dab16645921f62 /Lib/asyncio/proactor_events.py
parent2e3d873d3bd0ef4708c4fa06b6cd6972574cb9af (diff)
downloadcpython-1b53a24fb4417c764dd5933bce505f5c94249ca6.zip
cpython-1b53a24fb4417c764dd5933bce505f5c94249ca6.tar.gz
cpython-1b53a24fb4417c764dd5933bce505f5c94249ca6.tar.bz2
bpo-34679: ProactorEventLoop only uses set_wakeup_fd() in main thread (GH-16901)
bpo-34679, bpo-38563: asyncio.ProactorEventLoop.close() now only calls signal.set_wakeup_fd() in the main thread.
Diffstat (limited to 'Lib/asyncio/proactor_events.py')
-rw-r--r--Lib/asyncio/proactor_events.py6
1 files changed, 3 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.