Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f3c16a5

Browse files
jcristasvetlov
andauthored
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 <[email protected]>
1 parent 41026c3 commit f3c16a5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/asyncio/base_events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,7 @@ async def create_server(
13941394
sock=None,
13951395
backlog=100,
13961396
ssl=None,
1397+
reuse_address=None,
13971398
reuse_port=None,
13981399
ssl_handshake_timeout=None,
13991400
start_serving=True):
@@ -1424,6 +1425,8 @@ async def create_server(
14241425
raise ValueError(
14251426
'host/port and sock can not be specified at the same time')
14261427

1428+
if reuse_address is None:
1429+
reuse_address = os.name == "posix" and sys.platform != "cygwin"
14271430
sockets = []
14281431
if host == '':
14291432
hosts = [None]
@@ -1453,6 +1456,9 @@ async def create_server(
14531456
af, socktype, proto, exc_info=True)
14541457
continue
14551458
sockets.append(sock)
1459+
if reuse_address:
1460+
sock.setsockopt(
1461+
socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
14561462
if reuse_port:
14571463
_set_reuseport(sock)
14581464
# Disable IPv4/IPv6 dual stack support (enabled by

0 commit comments

Comments
 (0)