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

Function _is_process_running

Lib/profiling/sampling/sample.py:352–371  ·  view source on GitHub ↗
(pid)

Source from the content-addressed store, hash-verified

350
351
352def _is_process_running(pid):
353 if pid <= 0:
354 return False
355 if os.name == "posix":
356 try:
357 os.kill(pid, 0)
358 return True
359 except ProcessLookupError:
360 return False
361 except PermissionError:
362 # EPERM means process exists but we can't signal it
363 return True
364 elif sys.platform == "win32":
365 try:
366 _remote_debugging.RemoteUnwinder(pid)
367 except Exception:
368 return False
369 return True
370 else:
371 raise ValueError(f"Unsupported platform: {sys.platform}")
372
373
374def sample(

Callers 4

_handle_attachFunction · 0.90
sampleMethod · 0.85
sample_liveFunction · 0.85

Calls 1

killMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…