baldaquin.event
— Event handler#
The module provides the necessary facilities for asynchronous event handling.
EventHandlerBase
is an abstract
base class for runnable tasks that can be overloaded to create concrete
event handler to be used within the run control.
evt_handler = MyEventHandler(*args, **kwargs) # Note you need a concrete class, here.
pool = QtCore.QThreadPool.globalInstance()
pool.start(evt_handler)
# A concurrent thread can flush the data buffer to disk asynchronously...
evt_handler.stop()
pool.waitForDone()
evt_handler.buffer.flush()
In the dedault implementation the
run()
method is simply calling
process_event()
repeatedly (on a separate thread) and putting in the data buffer whatever
the latter returns, under the condition that the event handler is runnging.
Subclasses will overload
process_event()
to achieve the desired behavior.
You can look at MockEventHandler
for a
concrete example.