agent-exec transport d746852ae50f236002975c61a064caa9/397c60bd1367

This commit is contained in:
agent-exec-transport
2026-10-21 10:27:21 +00:00
parent 88aa4b6b7d
commit 70c810a030
4 changed files with 64 additions and 14 deletions
+13
View File
@@ -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]