When writing an asyncio based service, you basically have this sequence:
loop.run_forever()
loop.stop()
If there are any connections active at this point, then they don't get discarded until interpreter shutdown, with the result that you get a bunch of ResourceWarnings (and cleanup code might not run).
It would be very useful if there was a Server.close_clients()
or something like that. Even a Server.all_transports()
would be useful, as then you could do something similar as when doing a Task.cancel()
on what you get from loop.all_tasks()
.
We could poke at Server._transports
, but that is something internal that might change in the future.
There is Server.wait_closed()
, but that hangs until all clients have gracefully disconnected. It doesn't help us when we want to shut down the service now.
3.12
Operating systems tested on:Linux
Linked PRsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4