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

Method __exit__

Lib/profiling/sampling/_child_monitor.py:95–115  ·  view source on GitHub ↗
(self, exc_type, exc_val, exc_tb)

Source from the content-addressed store, hash-verified

93 return self
94
95 def __exit__(self, exc_type, exc_val, exc_tb):
96 self._stop_event.set()
97 if self._monitor_thread is not None:
98 self._monitor_thread.join(timeout=2.0)
99 if self._monitor_thread.is_alive():
100 print(
101 "Warning: Monitor thread did not stop cleanly",
102 file=sys.stderr,
103 )
104
105 # Wait for child profilers to complete naturally
106 self.wait_for_profilers()
107
108 # Terminate any remaining profilers
109 with self._lock:
110 profilers_to_cleanup = list(self._spawned_profilers)
111 self._spawned_profilers.clear()
112
113 for proc in profilers_to_cleanup:
114 self._cleanup_process(proc)
115 return False
116
117 def _cleanup_process(self, proc, terminate_timeout=2.0, kill_timeout=1.0):
118 if proc.poll() is not None:

Callers

nothing calls this directly

Calls 7

wait_for_profilersMethod · 0.95
_cleanup_processMethod · 0.95
listClass · 0.85
setMethod · 0.45
joinMethod · 0.45
is_aliveMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected