File tree Expand file tree Collapse file tree 4 files changed +17
-0
lines changed
Filter options
Expand file tree Collapse file tree 4 files changed +17
-0
lines changed
Original file line number Diff line number Diff line change @@ -671,6 +671,7 @@ Creating network servers
671
671
flags=socket.AI_PASSIVE, \
672
672
sock=None, backlog=100, ssl=None, \
673
673
reuse_address=None, reuse_port=None, \
674
+ keep_alive=None, \
674
675
ssl_handshake_timeout=None, \
675
676
ssl_shutdown_timeout=None, \
676
677
start_serving=True)
@@ -735,6 +736,13 @@ Creating network servers
735
736
set this flag when being created. This option is not supported on
736
737
Windows.
737
738
739
+ * *keep_alive * set to ``True `` keeps connections active by enabling the
740
+ periodic transmission of messages.
741
+
742
+ .. versionchanged :: 3.13
743
+
744
+ Added the *keep_alive * parameter.
745
+
738
746
* *ssl_handshake_timeout * is (for a TLS server) the time in seconds to wait
739
747
for the TLS handshake to complete before aborting the connection.
740
748
``60.0 `` seconds if ``None `` (default).
Original file line number Diff line number Diff line change @@ -1496,6 +1496,7 @@ async def create_server(
1496
1496
ssl = None ,
1497
1497
reuse_address = None ,
1498
1498
reuse_port = None ,
1499
+ keep_alive = None ,
1499
1500
ssl_handshake_timeout = None ,
1500
1501
ssl_shutdown_timeout = None ,
1501
1502
start_serving = True ):
@@ -1569,6 +1570,9 @@ async def create_server(
1569
1570
socket .SOL_SOCKET , socket .SO_REUSEADDR , True )
1570
1571
if reuse_port :
1571
1572
_set_reuseport (sock )
1573
+ if keep_alive :
1574
+ sock .setsockopt (
1575
+ socket .SOL_SOCKET , socket .SO_KEEPALIVE , True )
1572
1576
# Disable IPv4/IPv6 dual stack support (enabled by
1573
1577
# default on Linux) which makes a single socket
1574
1578
# listen on both address families.
Original file line number Diff line number Diff line change @@ -316,6 +316,7 @@ async def create_server(
316
316
* , family = socket .AF_UNSPEC ,
317
317
flags = socket .AI_PASSIVE , sock = None , backlog = 100 ,
318
318
ssl = None , reuse_address = None , reuse_port = None ,
319
+ keep_alive = None ,
319
320
ssl_handshake_timeout = None ,
320
321
ssl_shutdown_timeout = None ,
321
322
start_serving = True ):
@@ -354,6 +355,9 @@ async def create_server(
354
355
they all set this flag when being created. This option is not
355
356
supported on Windows.
356
357
358
+ keep_alive set to True keeps connections active by enabling the
359
+ periodic transmission of messages.
360
+
357
361
ssl_handshake_timeout is the time in seconds that an SSL server
358
362
will wait for completion of the SSL handshake before aborting the
359
363
connection. Default is 60s.
Original file line number Diff line number Diff line change
1
+ Add ``keep_alive `` keyword parameter for :meth: `AbstractEventLoop.create_server ` and :meth: `BaseEventLoop.create_server `.
You can’t perform that action at this time.
0 commit comments