python-websockets / python-websockets/websockets
Consider adding close_connections argument to serve
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 5.7k
- Forks
- 613
- Ø Merge
- 23 Std. 5 Min.
- Gemergte PRs (30 T.)
- 9
Beschreibung
The close / shutdown / aclose methods of servers (in asyncio / threading / trio implementations) take a close_connections argument to control whether the server should close connections proactively (the default behavior) or wait for clients to disconnect by themselves (which could be arbitrarily long).
When using serve as a context manager, there is no way to control this behavior. An obvious option would consist in adding a close_connections argument to serve, then proxy it to close / shutdown / aclose in __aexit__ / __exit__ / __aexit__.
If we do this, for completeness, we should also add close_code and close_reason. This means adding three arguments to serve. I'm not convinced that it's a good trade-off.
An alternative would consist in documenting the recommended pattern for controlling this behavior. Currently, the trio implementation shows an example of using aclose which can easily be extended with some parameter. The asyncio and threading implementations don't show examples of using close and shutdown.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Start by comparing the asyncio, threading, and trio serve implementations with their close, shutdown, and aclose methods. Decide whether serve should gain close_connections, close_code, and close_reason or whether documentation should show the recommended pattern; done means the chosen behavior is consistently implemented or documented across all three implementations.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api, backend, networking
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Aktiv
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100