summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorbeavailable <beavailable@proton.me>2023-12-13 03:23:29 (GMT)
committerGitHub <noreply@github.com>2023-12-13 03:23:29 (GMT)
commit3aea6c4823e90172c9bc36cd20dc51b295d8a3c4 (patch)
tree12040ee3f1f6e9fcb679b8be79905587281592ee /Lib/asyncio/base_events.py
parenta3a1cb48456c809f7b1ab6a6ffe83e8b3f69be0f (diff)
downloadcpython-3aea6c4823e90172c9bc36cd20dc51b295d8a3c4.zip
cpython-3aea6c4823e90172c9bc36cd20dc51b295d8a3c4.tar.gz
cpython-3aea6c4823e90172c9bc36cd20dc51b295d8a3c4.tar.bz2
gh-101336: Add keep_alive keyword arg for asyncio create_server() (#112485)
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 416c732..a8870b6 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1496,6 +1496,7 @@ class BaseEventLoop(events.AbstractEventLoop):
ssl=None,
reuse_address=None,
reuse_port=None,
+ keep_alive=None,
ssl_handshake_timeout=None,
ssl_shutdown_timeout=None,
start_serving=True):
@@ -1569,6 +1570,9 @@ class BaseEventLoop(events.AbstractEventLoop):
socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
if reuse_port:
_set_reuseport(sock)
+ if keep_alive:
+ sock.setsockopt(
+ socket.SOL_SOCKET, socket.SO_KEEPALIVE, True)
# Disable IPv4/IPv6 dual stack support (enabled by
# default on Linux) which makes a single socket
# listen on both address families.