asyncio proactor server leaks the accepted socket and stops accepting when transport creation fails
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Bug report
Bug description:
On the proactor event loop (the default on Windows), BaseProactorEventLoop._start_serving()'s loop() callback runs protocol_factory() and transport creation in the same callback that re-arms accept(), guarded only by except OSError / except CancelledError. When protocol_factory() or _make_ssl_transport() / _make_socket_transport() raises for an accepted connection:
- a non-
OSError(e.g. a failingprotocol_factory) propagates out ofloop(): the accepted socket is never closed (it leaks until garbage collection) and accept is not re-armed, so the server stops accepting new connections; - an
OSErroris caught as'Accept failed on a socket', which closes the listening socket, and still leaks the accepted socket.
This is the proactor counterpart of gh-155934 (selector accept) and gh-153133 (create_connection): an accepted socket must be closed when the transport is never created, and a per-connection failure must not tear down the listening socket or the accept loop.
Verified with mock-based tests in test_proactor_events (the same approach used for the selector fix in gh-155934), which run on all platforms.
CPython versions tested on:
CPython main
Operating systems tested on:
Windows (ProactorEventLoop)
Linked PRs
- gh-156366
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par BaseProactorEventLoop._start_serving() et les tests basés sur des mocks dans test_proactor_events. Reproduisez l’échec de création du protocole ou du transport, puis vérifiez que le socket accepté est fermé et que le serveur en écoute continue d’accepter des connexions. Comparez le travail existant dans la PR liée gh-156366 avant d’effectuer des modifications.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- networking, operating-systems
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 25/100