Consider adding close_connections argument to serve
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- python
- Domain
- api, backend, networking
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Python
- Stars
- 5.7k
- Forks
- 613
- Avg merge
- 23h 5m
- Merged PRs (30d)
- 9
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-websockets/websockets
-
Ping/pong frame logging can produce text that crashes non-UTF-8 log handlers (UnicodeEncodeError) Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
python-websockets/websockets#1763 · 9 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
python-websockets/websockets#1761 · 1 comment ·
All issues in python-websockets/websockets
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100