@contextmanager
def record_events():
    container = MultiThreadRecordContainer()
    recorder = MultiThreadChangeEventRecorder(container=container)
    trait_notifiers.set_change_event_tracers(
        pre_tracer=recorder.pre_tracer, post_tracer=recorder.post_tracer)

    try:
        yield container
    finally:
        trait_notifiers.clear_change_event_tracers()
        recorder.close()
Multi-threaded trait change event tracer.
dataset/ETHPy150Open enthought/traits/traits/util/event_tracer.py/record_events