You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Windows] asyncio: support signal handlers on Windows (feature request) #67246
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:
assignee=Noneclosed_at=<Date2018-12-18.21:58:01.757>created_at=<Date2014-12-15.20:10:56.825>labels= ['type-feature', '3.8', 'OS-windows', 'expert-asyncio']
title='[Windows] asyncio: support signal handlers on Windows (feature request)'updated_at=<Date2019-01-05.20:45:03.021>user='https://github.com/asvetlov'
changed the title [-]asyncio loop on Windows should stop on keyboard interrupt[/-][+][Windows] asyncio: support signal handlers on Windows (feature request)[/+]on Jan 26, 2015
It would be nice the patch mentioned was eventually applied.
DMRobertson commented on Jul 7, 2015
DMRobertsonmannequin
Mannequin
More actions
Dear all, I have just been trying to understand the TCP Echo example from the asyncio documentation: https://docs.python.org/3/library/asyncio-protocol.html#protocol-examples
I copied the two examples from the docs into server.py' and client.py'. I ran server.py first and hit control-C. This did not close the server as expected. However, if I then ran client.py, the act of sending a message to the server seemed to prompt it to receive the KeyboardInterrupt and close! In turn this caused an OSError to be raised by the client.
Some searching lead me to StackOverflow and then to this bug. I wanted to point out this behaviour, as I didn't see it mentioned in any of the previous comments. Plus, I thought it was a shame that the first example I looked didn't behave as described!
I'm curently running Python 3.3.1 on Windows 7 and I'm using asyncio 3.4.3 from PyPI.
Drekin commented on Jul 7, 2015
Drekinmannequin
Mannequin
More actions
David Robertson: The behaviour you pointed out is a consequence of the general issue: signals on Windows aren't fully supported. Basically, they cannot interrupt the event loop when every coroutine is waiting for something. Instead, they are fired when something happens – some data are recieved or some timer reaches zero. In your case it was the connection of the client or the message it sent.
This is the right issue related to your problem. Hopefully, it will be fixed eventually. A current workaround is to schedule a task which periodically sleeps for an amount of time. For example, if it allways sleeps for one second, then you will wait for KeyboardInterrupt at most one second.
New changeset b5c8cfa by Andrew Svetlov (Vladimir Matveev) in branch 'master': bpo-23057: add loop self socket as wakeup fd for signals (bpo-11135) b5c8cfa
#55483 desperately needs to be addressed! The 2 Windows 7 buildbots have been failing on 3.x since the merge of #55344 on 12-18. Either that or the commit b5c8cfa needs to be reverted.
Being the holiday season and all I can see the extra time needed for Python development is sparse, but 2 weeks without ensuring a commit doesn't break stable buildbots seems a bit much.
New changeset 67ba547 by Andrew Svetlov (Vladimir Matveev) in branch 'master': bpo-23057: Use 'raise' to emulate ctrl-c in proactor tests (bpo-11274) 67ba547
Activity
asvetlov commentedon Dec 15, 2014
See http://stackoverflow.com/questions/27480967/why-does-the-asyncios-event-loop-suppress-the-keyboardinterrupt-on-windows for details
vstinner commentedon Dec 16, 2014
Hi, I started to work on this topic a few months ago:
https://code.google.com/p/tulip/issues/detail?id=191
I should update my patches.
vstinner commentedon Dec 16, 2014
This issue is specific to Windows. On all others platforms, signal handling is nicely supported.
KimmoParviainen-Jalanko commentedon Dec 18, 2014
Seems to happen on FreeBSD 10.1 as well with 3.4.2
vstinner commentedon Dec 18, 2014
FreeBSD uses a completly different implementation. Please open a new issue, describe your problem and write a script reproducing your issue.
[-]asyncio loop on Windows should stop on keyboard interrupt[/-][+][Windows] asyncio: support signal handlers on Windows (feature request)[/+]akuchling commentedon Apr 13, 2015
Victor's patch has moved to python/asyncio#191 .
Drekin commentedon Jul 5, 2015
I've also run into this issue (see https://mail.python.org/pipermail/python-list/2015-July/693496.html and the following thread). I'm adding some small examples showing the behavior.
The following even smaller example by Terry Reedy and the OP from http://stackoverflow.com/questions/27480967/why-does-the-asyncios-event-loop-suppress-the-keyboardinterrupt-on-windows cannot be interrupted other way then shuting down whole process:
asyncio.get_event_loop().run_forever()
---
It would be nice the patch mentioned was eventually applied.
DMRobertson commentedon Jul 7, 2015
Dear all, I have just been trying to understand the TCP Echo example from the asyncio documentation:
https://docs.python.org/3/library/asyncio-protocol.html#protocol-examples
I copied the two examples from the docs into
server.py' andclient.py'. I ran server.py first and hit control-C. This did not close the server as expected. However, if I then ran client.py, the act of sending a message to the server seemed to prompt it to receive the KeyboardInterrupt and close! In turn this caused an OSError to be raised by the client.Some searching lead me to StackOverflow and then to this bug. I wanted to point out this behaviour, as I didn't see it mentioned in any of the previous comments. Plus, I thought it was a shame that the first example I looked didn't behave as described!
I'm curently running Python 3.3.1 on Windows 7 and I'm using asyncio 3.4.3 from PyPI.
Drekin commentedon Jul 7, 2015
David Robertson: The behaviour you pointed out is a consequence of the general issue: signals on Windows aren't fully supported. Basically, they cannot interrupt the event loop when every coroutine is waiting for something. Instead, they are fired when something happens – some data are recieved or some timer reaches zero. In your case it was the connection of the client or the message it sent.
This is the right issue related to your problem. Hopefully, it will be fixed eventually. A current workaround is to schedule a task which periodically sleeps for an amount of time. For example, if it allways sleeps for one second, then you will wait for KeyboardInterrupt at most one second.
asvetlov commentedon Dec 18, 2018
New changeset b5c8cfa by Andrew Svetlov (Vladimir Matveev) in branch 'master':
bpo-23057: add loop self socket as wakeup fd for signals (bpo-11135)
b5c8cfa
jkloth commentedon Dec 30, 2018
#55483 desperately needs to be addressed! The 2 Windows 7 buildbots have been failing on 3.x since the merge of #55344 on 12-18. Either that or the commit b5c8cfa needs to be reverted.
Being the holiday season and all I can see the extra time needed for Python development is sparse, but 2 weeks without ensuring a commit doesn't break stable buildbots seems a bit much.
asvetlov commentedon Jan 5, 2019
New changeset 67ba547 by Andrew Svetlov (Vladimir Matveev) in branch 'master':
bpo-23057: Use 'raise' to emulate ctrl-c in proactor tests (bpo-11274)
67ba547