diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2019-08-26 09:51:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-26 09:51:08 (GMT) |
commit | 1c0600998681295735a18690fae184b0c9a4ca51 (patch) | |
tree | e0fdc4d7f8b47b316a9f27c6b2e1eba27bd981c5 /Lib/asyncio | |
parent | 998cf1f03a61de8a0cd3811faa97973d4022bc55 (diff) | |
download | cpython-1c0600998681295735a18690fae184b0c9a4ca51.zip cpython-1c0600998681295735a18690fae184b0c9a4ca51.tar.gz cpython-1c0600998681295735a18690fae184b0c9a4ca51.tar.bz2 |
bpo-34679: Restore instantiation Windows IOCP event loop from non-main thread (#15492)
* Restore running proactor event loop from non-main thread
Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
Diffstat (limited to 'Lib/asyncio')
-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 9b8ae06..229f56e 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -11,6 +11,7 @@ import os import socket import warnings import signal +import threading import collections from . import base_events @@ -627,7 +628,9 @@ class BaseProactorEventLoop(base_events.BaseEventLoop): proactor.set_loop(self) self._make_self_pipe() self_no = self._csock.fileno() - signal.set_wakeup_fd(self_no) + 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) def _make_socket_transport(self, sock, protocol, waiter=None, extra=None, server=None): |