★ wanayoo — archive 1999 https://github.com/MagicStack/uvloop/pull/296Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KeyboardInterrupt handling logic. #296

Merged
merged 1 commit into from Oct 29, 2019
Merged

Fix KeyboardInterrupt handling logic. #296

merged 1 commit into from Oct 29, 2019

Conversation

@1st1
Copy link
Member

1st1 commented Oct 28, 2019

When uvloop is run in the main thread we always want to set up a
self-pipe and a signal wakeup FD. That's the only way how libuv
can be notified that a ^C happened and break away from selecting
on sockets.

asyncio does not need to do that, as the 'selectors' module it uses
is already aware of the way Python implements ^C handling.

This translates to a slightly different behavior between asyncio &
uvloop:

  1. uvloop needs to always call signal.set_wakeup_fd() when run in the
    main thread;

  2. asyncio only needs to call signal.set_wakeup_fd() when a user
    registers a signal handler.

(2) means that if the user had not set up any signals, the signal
wakeup FD stays the same between different asyncio runs. This commit
fixes uvloop signal implementation to make sure that uvloop behaves
the same way as asyncio in regards to signal wakeup FD between the
loop runs. It also ensures that uvloop always have a proper
self-pipe set up so that ^C is always supported when it is run in
the main thread.

Issue #295.

@1st1 1st1 force-pushed the sigint branch 2 times, most recently from 383fdc9 to 615bdc5 Oct 28, 2019
When uvloop is run in the main thread we *always* want to set up a
self-pipe and a signal wakeup FD.  That's the only way how libuv
can be notified that a ^C happened and break away from selecting
on sockets.

asyncio does not need to do that, as the 'selectors' module it uses
is already aware of the way Python implements ^C handling.

This translates to a slightly different behavior between asyncio &
uvloop:

1. uvloop needs to always call signal.set_wakeup_fd() when run in the
  main thread;

2. asyncio only needs to call signal.set_wakeup_fd() when a user
  registers a signal handler.

(2) means that if the user had not set up any signals, the signal
wakeup FD stays the same between different asyncio runs.  This commit
fixes uvloop signal implementation to make sure that uvloop behaves
the same way as asyncio in regards to signal wakeup FD between the
loop runs.  It also ensures that uvloop always have a proper
self-pipe set up so that ^C is always supported when it is run in
the main thread.

Issue #295.
@1st1 1st1 force-pushed the sigint branch from 615bdc5 to fa1fd10 Oct 29, 2019
@1st1 1st1 merged commit c32c703 into master Oct 29, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@1st1 1st1 deleted the sigint branch Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.