Skip to content

Commit 9d345f5

Browse files
tbodtOmer Katz
authored andcommitted
Set the SO_REUSEADDR option on the socket (celery#3969)
If the server exits before the client does, the port will appear to be in use for 90 seconds unless you set this option. TCP is annoying.
1 parent 13916de commit 9d345f5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

celery/contrib/rdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def get_avail_port(self, host, port, search_limit=100, skew=+0):
124124
this_port = None
125125
for i in range(search_limit):
126126
_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
127+
_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
127128
this_port = port + skew + i
128129
try:
129130
_sock.bind((host, this_port))

0 commit comments

Comments
 (0)