agent-exec transport d746852ae50f236002975c61a064caa9/397c60bd1367
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
"""Shared free-port helper for svc tests (not a test module)."""
|
||||
import socket
|
||||
|
||||
|
||||
def free_test_port():
|
||||
"""Return a port the kernel reports free on 127.0.0.1 right now.
|
||||
|
||||
Each call opens a fresh reservation and closes it before returning, so the
|
||||
caller (e.g. `svc deploy`) can bind the port itself. Ports are not pooled.
|
||||
"""
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as reservation:
|
||||
reservation.bind(("127.0.0.1", 0))
|
||||
return reservation.getsockname()[1]
|
||||
Reference in New Issue
Block a user