cytoflowgui.utility.event_tracer

Record trait change events in single and multi-threaded environments. Adapted from https://docs.enthought.com/traits/_modules/traits/util/event_tracer.html

class cytoflowgui.utility.event_tracer.SentinelRecord[source]

Bases: object

Sentinel record to separate groups of chained change event dispatches.

class cytoflowgui.utility.event_tracer.ChangeMessageRecord(time, indent, name, old, new, class_name)[source]

Bases: object

Message record for a change event dispatch.

time

Time stamp in UTC.

indent

Depth level in a chain of trait change dispatches.

name

The name of the trait that changed

old

The old value.

new

The new value.

class_name

The name of the class that the trait change took place.

class cytoflowgui.utility.event_tracer.CallingMessageRecord(time, indent, handler, source)[source]

Bases: object

Message record for a change handler call.

time

Time stamp in UTC.

indent

Depth level of the call in a chain of trait change dispatches.

handler

The traits change handler that is called.

source

The source file where the handler was defined.

class cytoflowgui.utility.event_tracer.ExitMessageRecord(time, indent, handler, exception)[source]

Bases: object

Message record for returning from a change event dispatch.

time

Time stamp in UTC.

indent

Depth level of the exit in a chain of trait change dispatch.

handler

The traits change handler that is called.

exception

The exception type (if one took place)

class cytoflowgui.utility.event_tracer.RecordContainer[source]

Bases: object

A simple record container.

This class is commonly used to hold records from a single thread.

record(record)[source]

Add the record into the container.

save_to_file(filename)[source]

Save the records into a file.

class cytoflowgui.utility.event_tracer.MultiThreadRecordContainer[source]

Bases: object

A container of record containers that are used by separate threads.

Each record container is mapped to a thread name id. When a RecordContainer does not exist for a specific thread a new empty RecordContainer will be created on request.

get_change_event_collector(thread_name)[source]

Return the dedicated RecordContainer for the thread.

If no RecordContainer is found for thread_name then a new RecordContainer is created.

save_to_directory(directory_name)[source]

Save records files into the directory.

Each RecordContainer will dump its records on a separate file named <thread_name>.trace.

class cytoflowgui.utility.event_tracer.ChangeEventRecorder(container)[source]

Bases: object

A single thread trait change event recorder.

pre_tracer(obj, name, old, new, handler)[source]

Record a string representation of the trait change dispatch

post_tracer(obj, name, old, new, handler, exception=None)[source]

Record a string representation of the trait change return

class cytoflowgui.utility.event_tracer.MultiThreadChangeEventRecorder(container)[source]

Bases: object

A thread aware trait change recorder.

The class manages multiple ChangeEventRecorders which record trait change events for each thread in a separate file.

close()[source]

Close and stop all logging.

pre_tracer(obj, name, old, new, handler)[source]

The traits pre event tracer.

This method should be set as the global pre event tracer for traits.

post_tracer(obj, name, old, new, handler, exception=None)[source]

The traits post event tracer.

This method should be set as the global post event tracer for traits.

cytoflowgui.utility.event_tracer.record_events()[source]

Multi-threaded trait change event tracer.:

from trace_recorder import record_events
with record_events() as change_event_container:
    my_model.some_trait = True
change_event_container.save_to_directory('C:\dev\trace')

This will install a tracer that will record all events that occur from setting of some_trait on the my_model instance.

The results will be stored in one file per running thread in the directory ‘C:devtrace’. The files are named after the thread being traced.