Efforts to make ucloud a python package

This commit is contained in:
ahmadbilalkhalid 2019-12-03 15:40:41 +05:00
commit 1e7300b56e
71 changed files with 241 additions and 1043 deletions

13
ucloud/host/helper.py Normal file
View file

@ -0,0 +1,13 @@
import socket
from contextlib import closing
def find_free_port():
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
try:
s.bind(('', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
except Exception:
return None
else:
return s.getsockname()[1]