summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorJim Crist-Harif <jcristharif@gmail.com>2021-12-12 09:47:01 (GMT)
committerGitHub <noreply@github.com>2021-12-12 09:47:01 (GMT)
commitf3c16a5e72aaf06bec863fa3a172f3deaa491bc9 (patch)
tree2b60286188441df7c60efcf98500223624b208d6 /Lib/asyncio
parent41026c3155012d6ea50e01205c163b6739c675b8 (diff)
downloadcpython-f3c16a5e72aaf06bec863fa3a172f3deaa491bc9.zip
cpython-f3c16a5e72aaf06bec863fa3a172f3deaa491bc9.tar.gz
cpython-f3c16a5e72aaf06bec863fa3a172f3deaa491bc9.tar.bz2
Re-add `reuse_address` parameter to `create_server` (GH-29733)
This parameter was accidentally removed when fixing https://bugs.python.org/issue45129, this reverts the unnecessary changes there. Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_events.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index cfaf082..cbf6d5d 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1394,6 +1394,7 @@ class BaseEventLoop(events.AbstractEventLoop):
sock=None,
backlog=100,
ssl=None,
+ reuse_address=None,
reuse_port=None,
ssl_handshake_timeout=None,
start_serving=True):
@@ -1424,6 +1425,8 @@ class BaseEventLoop(events.AbstractEventLoop):
raise ValueError(
'host/port and sock can not be specified at the same time')
+ if reuse_address is None:
+ reuse_address = os.name == "posix" and sys.platform != "cygwin"
sockets = []
if host == '':
hosts = [None]
@@ -1453,6 +1456,9 @@ class BaseEventLoop(events.AbstractEventLoop):
af, socktype, proto, exc_info=True)
continue
sockets.append(sock)
+ if reuse_address:
+ sock.setsockopt(
+ socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
if reuse_port:
_set_reuseport(sock)
# Disable IPv4/IPv6 dual stack support (enabled by