utils: catch error: [Errno 98] Address already in use errors
This commit is contained in:
parent
8be47ab771
commit
13a872fd35
1 changed files with 6 additions and 1 deletions
|
|
@ -36,6 +36,7 @@ import urlobject
|
|||
import uuid
|
||||
import getpass
|
||||
import socket
|
||||
import errno
|
||||
import random
|
||||
from functools import update_wrapper, partial, wraps
|
||||
|
||||
|
|
@ -1201,7 +1202,11 @@ def get_available_port(min_port=40000, max_port=55555):
|
|||
sock.close()
|
||||
break
|
||||
except OSError:
|
||||
pass
|
||||
continue
|
||||
except socket.error as e:
|
||||
if e.args[0] in [errno.EADDRINUSE, errno.ECONNREFUSED]:
|
||||
continue
|
||||
raise
|
||||
|
||||
del sock
|
||||
return pick_port
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue