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

Adding selectors has two KeyError exceptions in the success path #106664

Closed
bdraco opened this issue Jul 12, 2023 · 0 comments
Closed

Adding selectors has two KeyError exceptions in the success path #106664

bdraco opened this issue Jul 12, 2023 · 0 comments
Labels
performance Performance or resource usage topic-asyncio type-feature A feature request or enhancement

Comments

@bdraco
Copy link
Contributor

bdraco commented Jul 12, 2023

Similar to #106527, adding a new asyncio reader has to hit _SelectorMapping.__getitem__ which is expected to raise and catch KeyError twice since the reader will not yet be in the map.

When connections are constantly being added and removed because devices are being polled over http/websocket the overhead of adding/removing readers adds up.

For a webserver with connections constantly being added/removed, the cost of adding and removing impacts how many clients can be handled

Another place I see this come up is with dbus connections which need to get torn down and created at fast clip when dealing with bluetooth devices.

See #106527 (comment) and #106527 (comment) for where this was split from

Linked PRs

@bdraco bdraco added the type-feature A feature request or enhancement label Jul 12, 2023
@AlexWaygood AlexWaygood added topic-asyncio performance Performance or resource usage labels Jul 12, 2023
methane added a commit that referenced this issue Jul 13, 2023
It can be used to avoid raising and catching KeyError twice via __getitem__.

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
kgdiem pushed a commit to kgdiem/cpython that referenced this issue Jul 14, 2023
…hon#106665)

It can be used to avoid raising and catching KeyError twice via __getitem__.

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage topic-asyncio type-feature A feature request or enhancement
Projects
Status: Done
Development

No branches or pull requests

3 participants