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

Function _wait_for_ready_signal

Lib/profiling/sampling/cli.py:220–247  ·  view source on GitHub ↗

Wait for the ready signal from the subprocess, checking for early death.

(sync_sock, process, timeout)

Source from the content-addressed store, hash-verified

218
219
220def _wait_for_ready_signal(sync_sock, process, timeout):
221 """Wait for the ready signal from the subprocess, checking for early death."""
222 deadline = time.monotonic() + timeout
223 sel = selectors.DefaultSelector()
224 sel.register(sync_sock, selectors.EVENT_READ)
225
226 try:
227 while True:
228 _check_process_died(process)
229
230 remaining = deadline - time.monotonic()
231 if remaining <= 0:
232 raise socket.timeout("timed out")
233
234 if not sel.select(timeout=min(0.1, remaining)):
235 continue
236
237 conn, _ = sync_sock.accept()
238 try:
239 ready_signal = conn.recv(_RECV_BUFFER_SIZE)
240 finally:
241 conn.close()
242
243 if ready_signal != _READY_MESSAGE:
244 raise RuntimeError(f"Invalid ready signal received: {ready_signal!r}")
245 return
246 finally:
247 sel.close()
248
249
250def _run_with_sync(original_cmd, suppress_output=False):

Callers 1

_run_with_syncFunction · 0.85

Calls 7

_check_process_diedFunction · 0.85
registerMethod · 0.45
timeoutMethod · 0.45
selectMethod · 0.45
acceptMethod · 0.45
recvMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…