gh-112989: asyncio: Reduce overhead to connect sockets with SelectorEventLoop (#112991)

_ensure_fd_no_transport had a KeyError in the success path
This commit is contained in:
J. Nick Koston 2023-12-12 14:29:21 -10:00 committed by GitHub
parent a3c031884d
commit 7e2d93f30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -261,15 +261,11 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
except (AttributeError, TypeError, ValueError):
# This code matches selectors._fileobj_to_fd function.
raise ValueError(f"Invalid file object: {fd!r}") from None
try:
transport = self._transports[fileno]
except KeyError:
pass
else:
if not transport.is_closing():
raise RuntimeError(
f'File descriptor {fd!r} is used by transport '
f'{transport!r}')
transport = self._transports.get(fileno)
if transport and not transport.is_closing():
raise RuntimeError(
f'File descriptor {fd!r} is used by transport '
f'{transport!r}')
def _add_reader(self, fd, callback, *args):
self._check_closed()

View File

@ -0,0 +1 @@
Reduce overhead to connect sockets with :mod:`asyncio` SelectorEventLoop.