Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Support SIGINT signal on Windows #191

Closed
GoogleCodeExporter opened this issue Apr 10, 2015 · 12 comments
Closed

Support SIGINT signal on Windows #191

GoogleCodeExporter opened this issue Apr 10, 2015 · 12 comments

Comments

@GoogleCodeExporter
Copy link

Currently, it's not possible to stop an event loop on Windows with CTRL+c 
(SIGINT signal). The feature should be implemented in SelectorEventLoop and/or 
ProactorEventLoop.

For SelectorEventLoop:

I tried to call "signal.set_wakeup_fd(self._csock.fileno())" where
self._csock is read end of the "self" pipe of the event loop, used to
wakeup the event loop on call_soon_threadsafe() or signals.

The problem is that set_wakeup_fd() expects a file, whereas
SelectorEventLoop uses a socket pair for the "self" pipe. Using a file
would be an issue with select.select() because it only supports
sockets...

I modified locally set_wakeup_fd() to use send() instead of write()
and accept sockets: it works!


For ProactorEventLoop:

There is an "Event" used by the C signal handler of Python: the event
is set when Python gets a SIGINT signal. The event is now private, but
it might be possible to retrieve it using ctypes or a modification of
Python 3.5.

It should be possible to register to event into the IOCP event loop to
wake up the event loop when the event is set. I didn't try to
implement it.


Until asyncio supports SIGINT on Windows, a workaround is to use a
periodic task to interrupt the event loop every N seconds.

Original issue reported on code.google.com by victor.s...@gmail.com on 16 Jul 2014 at 3:15

@stefanotorresi
Copy link

stefanotorresi commented Aug 30, 2016

I'm not clear whether or not this should be fixed by https://bugs.python.org/issue22018, but I still can reproduce the issue with python 3.5.2

@gvanrossum
Copy link
Member

Can you please open a new issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants