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)
| 79 | |
| 80 | |
| 81 | def _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 | |
| 109 | def _setup_environment(cwd: str) -> None: |
no test coverage detected
searching dependent graphs…