Writer synchronization
Summary of current writer:
- Runs as a python process:
python -m id21blissutils.server.nxscanwriter session_name
- Spawns and joins the main writer greenlet:
# id21blissutils/server/nxscanwriter.py def main(session_name, **kwargs): """ :param str session_name: :param **kwargs: see `listen_session_scans` :returns Greenlet: """ ...
- The "main" Greenlet listens to the specified session node in Redis and process 2 events:
- NEW_NODE (scan starts): creates a new Greenlet which will write data for this particular scan
- END_SCAN (scan done): triggers an external event on the scan node which is picked up but the writer thread (not visible to anyone else) which finishes the writing of this scan and exits
Synchronization needed
First proposal:
- Main greenlet (has a
dict
of writer greenlets)- OUT: start (started listening to the session node)
- OUT: end (stopped listening to the session node)
- IN: start listening
- IN: stop listening
- IN: stop writers
- IN: stop writers and stop listening
- Writer greenlet (one per scan):
- OUT: start (started listening to the scan node)
- OUT: end successfully
- OUT: end unsuccessfully (with message)
- OUT: end unsuccessfully with exception (with traceback)
- OUT: progress (issue: each channel has its own progress, some scans run indefinitely)
Remarks: there is no reason we cannot listen to multiple sessions at once. Currently only one session.