diff options
author | Vladimir Matveev <v2matveev@outlook.com> | 2018-12-18 21:56:17 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2018-12-18 21:56:17 (GMT) |
commit | b5c8cfa1da17c6f3acac80a0afca7f7104fb9589 (patch) | |
tree | d725abe7cb749e02672c269d7edc7bbcfd8faab6 /Lib/asyncio/proactor_events.py | |
parent | e3666fc8effb05b555121f4ab7388df59e21f8b4 (diff) | |
download | cpython-b5c8cfa1da17c6f3acac80a0afca7f7104fb9589.zip cpython-b5c8cfa1da17c6f3acac80a0afca7f7104fb9589.tar.gz cpython-b5c8cfa1da17c6f3acac80a0afca7f7104fb9589.tar.bz2 |
bpo-23057: add loop self socket as wakeup fd for signals (#11135)
Diffstat (limited to 'Lib/asyncio/proactor_events.py')
-rw-r--r-- | Lib/asyncio/proactor_events.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 69d96a8..9b9e0aa 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -10,6 +10,7 @@ import io import os import socket import warnings +import signal from . import base_events from . import constants @@ -489,6 +490,8 @@ 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() + signal.set_wakeup_fd(self_no) def _make_socket_transport(self, sock, protocol, waiter=None, extra=None, server=None): @@ -529,6 +532,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): if self.is_closed(): return + 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. @@ -613,7 +617,6 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): self._ssock.setblocking(False) self._csock.setblocking(False) self._internal_fds += 1 - self.call_soon(self._loop_self_reading) def _loop_self_reading(self, f=None): try: |