mirror of
https://github.com/python/cpython.git
synced 2025-11-14 07:49:28 +00:00
gh-101336: Add keep_alive keyword arg for asyncio create_server() (#112485)
This commit is contained in:
parent
a3a1cb4845
commit
3aea6c4823
4 changed files with 17 additions and 0 deletions
|
|
@ -671,6 +671,7 @@ Creating network servers
|
||||||
flags=socket.AI_PASSIVE, \
|
flags=socket.AI_PASSIVE, \
|
||||||
sock=None, backlog=100, ssl=None, \
|
sock=None, backlog=100, ssl=None, \
|
||||||
reuse_address=None, reuse_port=None, \
|
reuse_address=None, reuse_port=None, \
|
||||||
|
keep_alive=None, \
|
||||||
ssl_handshake_timeout=None, \
|
ssl_handshake_timeout=None, \
|
||||||
ssl_shutdown_timeout=None, \
|
ssl_shutdown_timeout=None, \
|
||||||
start_serving=True)
|
start_serving=True)
|
||||||
|
|
@ -735,6 +736,13 @@ Creating network servers
|
||||||
set this flag when being created. This option is not supported on
|
set this flag when being created. This option is not supported on
|
||||||
Windows.
|
Windows.
|
||||||
|
|
||||||
|
* *keep_alive* set to ``True`` keeps connections active by enabling the
|
||||||
|
periodic transmission of messages.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.13
|
||||||
|
|
||||||
|
Added the *keep_alive* parameter.
|
||||||
|
|
||||||
* *ssl_handshake_timeout* is (for a TLS server) the time in seconds to wait
|
* *ssl_handshake_timeout* is (for a TLS server) the time in seconds to wait
|
||||||
for the TLS handshake to complete before aborting the connection.
|
for the TLS handshake to complete before aborting the connection.
|
||||||
``60.0`` seconds if ``None`` (default).
|
``60.0`` seconds if ``None`` (default).
|
||||||
|
|
|
||||||
|
|
@ -1496,6 +1496,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
||||||
ssl=None,
|
ssl=None,
|
||||||
reuse_address=None,
|
reuse_address=None,
|
||||||
reuse_port=None,
|
reuse_port=None,
|
||||||
|
keep_alive=None,
|
||||||
ssl_handshake_timeout=None,
|
ssl_handshake_timeout=None,
|
||||||
ssl_shutdown_timeout=None,
|
ssl_shutdown_timeout=None,
|
||||||
start_serving=True):
|
start_serving=True):
|
||||||
|
|
@ -1569,6 +1570,9 @@ class BaseEventLoop(events.AbstractEventLoop):
|
||||||
socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
|
socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
|
||||||
if reuse_port:
|
if reuse_port:
|
||||||
_set_reuseport(sock)
|
_set_reuseport(sock)
|
||||||
|
if keep_alive:
|
||||||
|
sock.setsockopt(
|
||||||
|
socket.SOL_SOCKET, socket.SO_KEEPALIVE, True)
|
||||||
# Disable IPv4/IPv6 dual stack support (enabled by
|
# Disable IPv4/IPv6 dual stack support (enabled by
|
||||||
# default on Linux) which makes a single socket
|
# default on Linux) which makes a single socket
|
||||||
# listen on both address families.
|
# listen on both address families.
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,7 @@ class AbstractEventLoop:
|
||||||
*, family=socket.AF_UNSPEC,
|
*, family=socket.AF_UNSPEC,
|
||||||
flags=socket.AI_PASSIVE, sock=None, backlog=100,
|
flags=socket.AI_PASSIVE, sock=None, backlog=100,
|
||||||
ssl=None, reuse_address=None, reuse_port=None,
|
ssl=None, reuse_address=None, reuse_port=None,
|
||||||
|
keep_alive=None,
|
||||||
ssl_handshake_timeout=None,
|
ssl_handshake_timeout=None,
|
||||||
ssl_shutdown_timeout=None,
|
ssl_shutdown_timeout=None,
|
||||||
start_serving=True):
|
start_serving=True):
|
||||||
|
|
@ -354,6 +355,9 @@ class AbstractEventLoop:
|
||||||
they all set this flag when being created. This option is not
|
they all set this flag when being created. This option is not
|
||||||
supported on Windows.
|
supported on Windows.
|
||||||
|
|
||||||
|
keep_alive set to True keeps connections active by enabling the
|
||||||
|
periodic transmission of messages.
|
||||||
|
|
||||||
ssl_handshake_timeout is the time in seconds that an SSL server
|
ssl_handshake_timeout is the time in seconds that an SSL server
|
||||||
will wait for completion of the SSL handshake before aborting the
|
will wait for completion of the SSL handshake before aborting the
|
||||||
connection. Default is 60s.
|
connection. Default is 60s.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Add ``keep_alive`` keyword parameter for :meth:`AbstractEventLoop.create_server` and :meth:`BaseEventLoop.create_server`.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue