MCPcopy Create free account
hub / github.com/EasyIME/PIME / refusing_port

Function refusing_port

python/python3/tornado/test/util.py:62–79  ·  view source on GitHub ↗

Returns a local port number that will refuse all connections. Return value is (cleanup_func, port); the cleanup function must be called to free the port to be reused.

()

Source from the content-addressed store, hash-verified

60
61
62def refusing_port():
63 """Returns a local port number that will refuse all connections.
64
65 Return value is (cleanup_func, port); the cleanup function
66 must be called to free the port to be reused.
67 """
68 # On travis-ci, port numbers are reassigned frequently. To avoid
69 # collisions with other tests, we use an open client-side socket's
70 # ephemeral port number to ensure that nothing can listen on that
71 # port.
72 server_socket, port = bind_unused_port()
73 server_socket.setblocking(True)
74 client_socket = socket.socket()
75 client_socket.connect(("127.0.0.1", port))
76 conn, client_addr = server_socket.accept()
77 conn.close()
78 server_socket.close()
79 return (client_socket.close, client_addr[1])
80
81
82def exec_test(caller_globals, caller_locals, s):

Callers 3

test_refused_ipv4Method · 0.90

Calls 4

bind_unused_portFunction · 0.90
acceptMethod · 0.80
connectMethod · 0.45
closeMethod · 0.45

Tested by 3

test_refused_ipv4Method · 0.72