Skip to content

bpo-39622: Use a custom signal handler in asyncio.run() #18628

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

Conversation

kmaork
Copy link
Contributor

@kmaork kmaork commented Feb 23, 2020

In short - the default python SIGINT handler can cause the event loop to lose handles and get stuck. Therefore when running a loop we should use a SIGINT handler more fitting to the situation.
See detailed explanation (and bug demo scripts) here - https://bugs.python.org/issue39622

https://bugs.python.org/issue39622

Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this with @1st1 and declined because the approach cannot interrupt the infinite loop without yield-point, e.g.

while True:
    pass

@kmaork kmaork force-pushed the bpo-39622-use-custom-sigint-handler-in-asyncio-run branch from 07e04c6 to cbcc88f Compare February 26, 2020 22:52
@kmaork
Copy link
Contributor Author

kmaork commented Feb 26, 2020

Thank you for your review. I've responded on the thread in https://bugs.python.org/issue39622

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@kmaork kmaork force-pushed the bpo-39622-use-custom-sigint-handler-in-asyncio-run branch from cbcc88f to 68e1a6f Compare February 28, 2020 11:04
@kmaork kmaork force-pushed the bpo-39622-use-custom-sigint-handler-in-asyncio-run branch from 68e1a6f to eb98f73 Compare February 28, 2020 17:51
@codecov
Copy link

codecov bot commented Feb 28, 2020

Codecov Report

Merging #18628 into master will increase coverage by 1.09%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #18628       +/-   ##
===========================================
+ Coverage   82.12%   83.22%    +1.09%     
===========================================
  Files        1956     1571      -385     
  Lines      589917   415337   -174580     
  Branches    44479    44489       +10     
===========================================
- Hits       484497   345666   -138831     
+ Misses      95770    60023    -35747     
+ Partials     9650     9648        -2     
Impacted Files Coverage Δ
Lib/distutils/tests/test_bdist_rpm.py 30.00% <0.00%> (-65.00%) ⬇️
Lib/distutils/command/bdist_rpm.py 7.63% <0.00%> (-56.88%) ⬇️
Lib/test/test_urllib2net.py 76.92% <0.00%> (-13.85%) ⬇️
Lib/test/test_smtpnet.py 78.57% <0.00%> (-7.15%) ⬇️
Lib/ftplib.py 63.85% <0.00%> (-6.06%) ⬇️
Lib/test/test_ftplib.py 87.11% <0.00%> (-4.72%) ⬇️
Tools/scripts/db2pickle.py 17.82% <0.00%> (-3.97%) ⬇️
Tools/scripts/pickle2db.py 16.98% <0.00%> (-3.78%) ⬇️
Lib/test/test_socket.py 71.94% <0.00%> (-3.77%) ⬇️
Lib/test/test_asyncio/test_base_events.py 92.02% <0.00%> (-3.12%) ⬇️
... and 442 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4f17c5c...616bf89. Read the comment docs.

@kmaork kmaork force-pushed the bpo-39622-use-custom-sigint-handler-in-asyncio-run branch 3 times, most recently from 8baf245 to 2bf50eb Compare February 29, 2020 09:43
@kmaork kmaork force-pushed the bpo-39622-use-custom-sigint-handler-in-asyncio-run branch from 2bf50eb to 616bf89 Compare February 29, 2020 10:07
@kmaork
Copy link
Contributor Author

kmaork commented May 8, 2020

Hey, @asvetlov @1st1 , did you see my changes?

@1st1
Copy link
Member

1st1 commented May 13, 2020

Actually I kind of like this approach. @asvetlov?

@kmaork
Copy link
Contributor Author

kmaork commented Jul 2, 2020

Hello there @asvetlov, @1st1, it's been some time! I Shouldn't we at least change the tag to "awaiting review"?

@remilapeyre
Copy link
Contributor

Hello there @asvetlov, @1st1, it's been some time! I Shouldn't we at least change the tag to "awaiting review"?

Hi @kmaork, as said in #18628 (comment) you can reply with "I have made the requested changes; please review again" and the tag will be updated.

@kmaork
Copy link
Contributor Author

kmaork commented Jul 2, 2020

Damn, completely missed that. Thanks! I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@1st1: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from 1st1 July 2, 2020 20:49
@itay-sho
Copy link

Hey there! I have encountered exactly this issue. any chance that it'll be merged any time soon?

@kmaork kmaork requested a review from asvetlov December 16, 2021 16:24
Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kmaork could you please synchronize the PR with the main branch before I'll start the actual review process?

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@asvetlov
Copy link
Contributor

Closed for the sake of #32105

@asvetlov asvetlov closed this Mar 30, 2022
@asvetlov
Copy link
Contributor

Thanks for the inspiration!

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

Successfully merging this pull request may close these issues.

7 participants