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.

Rewrite signal handling: use the self pipe #192

@GoogleCodeExporter

Description

@GoogleCodeExporter
Hi,

I noticied a race condition on FreeBSD when handling signals in asyncio when 
the Python main thread and a C thread are running at the "same time":
http://bugs.python.org/issue21645

I propose to not rely on signal.signal() to call 
_UnixSelectorEventLoop._handle_signal(), but use instead bytes written into the 
"wakeup fd" which is the loop "self" pipe.

Patch:
http://codereview.appspot.com/113160044

The patch changes the design of signal handling to fix the race condition:

1. C signal handler writes a byte in the "self" pipe
2. The event loop is awaken, reads its "self" pipe and schedules the call to 
the final signal handler
3. The signal handler is called

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions