`add_signal_handler` support for all platforms
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
I'm currently writing this to support signals on Windows and Linux:
loop = asyncio.get_running_loop()
def shutdown(*args):
// some shutdown sequence
if sys.platform == "win32":
for sig in (signal.SIGINT, signal.SIGTERM):
signal.signal(sig, shutdown)
else:
for sig in (signal.SIGINT, signal.SIGTERM):
loop.add_signal_handler(sig, shutdown)
Works great, but why would signal.signal be supported on Linux and Windows, but asyncio's AbstractEventLoop via add_signal_handler only on Linux? Can't this be platform agnostic?
add_signal_handler would raise the following on Windows:
[...]\Python\Python313\Lib\asyncio\events.py", line 596, in add_signal_handler
raise NotImplementedError
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with asyncio.AbstractEventLoop.add_signal_handler and the NotImplementedError shown at Python313/Lib/asyncio/events.py line 596, then compare it with signal.signal on Windows and Linux. Done means establishing whether add_signal_handler can provide the requested cross-platform behavior and documenting or implementing the resulting platform support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100