mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-113538: Add asycio.Server.{close,abort}_clients (#114432)
These give applications the option of more forcefully terminating client connections for asyncio servers. Useful when terminating a service and there is limited time to wait for clients to finish up their work.
This commit is contained in:
parent
872c0714fc
commit
1d0d49a7e8
8 changed files with 152 additions and 20 deletions
|
@ -1641,6 +1641,31 @@ Do not instantiate the :class:`Server` class directly.
|
|||
coroutine to wait until the server is closed (and no more
|
||||
connections are active).
|
||||
|
||||
.. method:: close_clients()
|
||||
|
||||
Close all existing incoming client connections.
|
||||
|
||||
Calls :meth:`~asyncio.BaseTransport.close` on all associated
|
||||
transports.
|
||||
|
||||
:meth:`close` should be called before :meth:`close_clients` when
|
||||
closing the server to avoid races with new clients connecting.
|
||||
|
||||
.. versionadded:: 3.13
|
||||
|
||||
.. method:: abort_clients()
|
||||
|
||||
Close all existing incoming client connections immediately,
|
||||
without waiting for pending operations to complete.
|
||||
|
||||
Calls :meth:`~asyncio.WriteTransport.abort` on all associated
|
||||
transports.
|
||||
|
||||
:meth:`close` should be called before :meth:`abort_clients` when
|
||||
closing the server to avoid races with new clients connecting.
|
||||
|
||||
.. versionadded:: 3.13
|
||||
|
||||
.. method:: get_loop()
|
||||
|
||||
Return the event loop associated with the server object.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue