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

Function capture_events

Lib/test/test_sys_setprofile.py:418–432  ·  view source on GitHub ↗
(callable, p=None)

Source from the content-addressed store, hash-verified

416
417
418def capture_events(callable, p=None):
419 if p is None:
420 p = HookWatcher()
421 # Disable the garbage collector. This prevents __del__s from showing up in
422 # traces.
423 old_gc = gc.isenabled()
424 gc.disable()
425 try:
426 sys.setprofile(p.callback)
427 protect(callable, p)
428 sys.setprofile(None)
429 finally:
430 if old_gc:
431 gc.enable()
432 return p.get_events()[1:-1]
433
434
435def show_events(callable):

Callers 2

check_eventsMethod · 0.85
show_eventsFunction · 0.85

Calls 5

get_eventsMethod · 0.95
HookWatcherClass · 0.85
protectFunction · 0.85
disableMethod · 0.45
enableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…