MCPcopy Index your code
hub / github.com/plotly/plotly.py / find_open_port

Function find_open_port

plotly/io/_orca.py:97–112  ·  view source on GitHub ↗

Use the socket module to find an open port. Returns ------- int An open port

()

Source from the content-addressed store, hash-verified

95
96
97def find_open_port():
98 """
99 Use the socket module to find an open port.
100
101 Returns
102 -------
103 int
104 An open port
105 """
106 s = socket.socket()
107 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
108 s.bind(("", 0))
109 _, port = s.getsockname()
110 s.close()
111
112 return port
113
114
115def retry(min_wait=5, max_wait=10, max_delay=60000):

Callers 1

ensure_serverFunction · 0.85

Calls 2

bindMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected