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: re-raise RuntimeError when uvloop raises RuntimeError during connect #105

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Sep 30, 2024

What do these changes do?

Its possible that uvloop raises RuntimeError during connect. ie RuntimeError: File descriptor 59 is used by transport <TCPTransport closed=False reading=True 0x55a6ec5c9460>. Currently we don't trap RuntimeError as the code copied from asyncio.base_events assumed only OSError can happen. Its possible that selector_events can raise RuntimeError as well https://github.com/python/cpython/blob/e44eebfc1eccdaaebc219accbfc705c9a9de068d/Lib/asyncio/selector_events.py#L271 but it doesn't seem to happen in practice as the root cause appears to be a bug in uvloop. It may be that loop.sock_connect is not cancellation safe in uvloop and is leaking the socket fd allocation on cancel or something else...

The file descriptor reuse in uvloop is not fixed by this PR. This is something that must be fixed in uvloop itself

Are there changes in behavior for the user?

no

Related issue number

#93

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b075f25) to head (23f6bd4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #105   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          198       201    +3     
  Branches        45        47    +2     
=========================================
+ Hits           198       201    +3     
Flag Coverage Δ
99.00% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco bdraco changed the title fix: improve logging when uvloop raises RuntimeError during connect fix: re-raise RuntimeError when uvloop raises RuntimeError during connect Sep 30, 2024
@bdraco bdraco marked this pull request as ready for review September 30, 2024 19:33
@bdraco bdraco merged commit c8f1fa9 into main Sep 30, 2024
28 checks passed
@bdraco bdraco deleted the uvloop_logging branch September 30, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant