-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio should use signal.set_wakeup_fd on Windows #77373
Comments
I thought there was already a bug for this, but it came up in conversation again and I can't find one, so, here you go... It looks like originally there was this bug for making control-C wake up the asyncio event loop in Windows: python/asyncio#191 This required some changes to signal.set_wakeup_fd to work on Windows, which was done in bpo-22018. But I guess the last step got lost in the shuffle: right now signal.set_wakeup_fd works fine on Windows, but asyncio doesn't actually use it. This means that on Windows you can't wake up this program using control-C:
Both of the Windows event loops should register a wakeup socket with signal.set_wakeup_fd, and arrange for the loop to wake up when data arrives on that socket, and read from it until it's empty again. (And once the loop is awake, Python's normal control-C handling will kick in.) That will make control-C on Windows work similarly to how it does on Unix. |
It looks like |
Is _WindowsSelectorEventLoop still relevant in Python 3.12, since ProactorEventLoop is now feature complete? (CTRL+C, signals, subprocesses, TLS sockets, etc.) |
IIUC the (sockets) selector event loop is still needed if you want to wait for a socket fd that was created outside of asyncio. Those use integers but they are not in the same namespace as file fds: both are ints, but the set of C-level APIs that accept one or the other are distinct, so you can't pass a socket fd to read(), you must use recv(). If I am wrong we should just start the deprecation process for _WindowsSelectorEventLoop, and then we can close this. |
Ah right, ProactorEventLoop lacks add_reader() and add_writer() methods: https://docs.python.org/dev/library/asyncio-platforms.html#asyncio-platform-support I don't know if it's an issue in practice. ProactorEventLoop has methods like |
I don't use asyncio on Windows (or anywhere else, but don't tell anyone, I'm trying to pose as an expert :-), so fine to start the deprecation process. Doesn't it require a PEP nowadays? |
To deprecate an asyncio feature, check if anyone uses it. If the usage is limited, PEP 387 gives the process. I ran a quick code search:
It's used in multiple projects. Some examples:
In these examples, the argument is a pipe, not a socket. But I don't know if such code is used on Windows, or only on Unix-like operating systems which are based on file descriptors (select, epoll, kqueue, etc.). |
Related issue: issue #71019 "ProactorEventLoop doesn't support stdin/stdout nor files with connect_read_pipe/connect_write_pipe" |
Someone would have to do more research. :-( |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: