Files
Isi-dev-ComfyUI-UniAnimate-W/utils/multi_port.py
T
2024-08-01 22:14:08 +01:00

20 lines
772 B
Python

<<<<<<< HEAD
import socket
from contextlib import closing
def find_free_port():
""" https://stackoverflow.com/questions/1365265/on-localhost-how-do-i-pick-a-free-port-number """
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
s.bind(('', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
=======
import socket
from contextlib import closing
def find_free_port():
""" https://stackoverflow.com/questions/1365265/on-localhost-how-do-i-pick-a-free-port-number """
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
s.bind(('', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>>>>>>> 626e7afc02230297b6f553675ea1c32c29971314
return str(s.getsockname()[1])