MCPcopy Index your code
hub / github.com/python/cpython / _signal_readiness

Function _signal_readiness

Lib/profiling/sampling/_sync_coordinator.py:81–106  ·  view source on GitHub ↗

Signal readiness to the profiler via TCP socket. Args: sync_port: Port number where profiler is listening Raises: SyncError: If unable to signal readiness

(sync_port: int)

Source from the content-addressed store, hash-verified

79
80
81def _signal_readiness(sync_port: int) -> None:
82 """
83 Signal readiness to the profiler via TCP socket.
84
85 Args:
86 sync_port: Port number where profiler is listening
87
88 Raises:
89 SyncError: If unable to signal readiness
90 """
91 last_error = None
92
93 for attempt in range(_MAX_RETRIES):
94 try:
95 # Use context manager for automatic cleanup
96 with socket.create_connection(("127.0.0.1", sync_port), timeout=_SOCKET_TIMEOUT_SEC) as sock:
97 sock.send(_READY_MESSAGE)
98 return
99 except (socket.error, OSError) as e:
100 last_error = e
101 if attempt < _MAX_RETRIES - 1:
102 # Exponential backoff before retry
103 time.sleep(_INITIAL_RETRY_DELAY_SEC * (2 ** attempt))
104
105 # If we get here, all retries failed
106 raise SyncError(f"Failed to signal readiness after {_MAX_RETRIES} attempts: {last_error}") from last_error
107
108
109def _setup_environment(cwd: str) -> None:

Callers 1

mainFunction · 0.85

Calls 4

SyncErrorClass · 0.85
create_connectionMethod · 0.45
sendMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…