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

Support SIGINT signal on Windows #191

Description

@GoogleCodeExporter
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions