UUTrack.Model.workerSaver¶
When working with multi threading in Python it is important to define the function that will be run in a separate thread. workerSaver is just a function that will be moved to a separate, parallel thread to save data to disk without interrupting the acquisition.
Since the workerSaver function will be passed to a different Process (via the multiprocessing package) the only way for it to receive data from other threads is via a Queue. The workerSaver will run continuously until it finds a string as the next item.
To understand how the separate process is created, please refer to
movieSave()
The general principle is
>>> filename = 'name.hdf5'
>>> q = Queue()
>>> metadata = _session.serialize() # This prints a YAML-ready version of the session.
>>> p = Process(target=workerSaver, args=(filename, metaData, q,))
>>> p.start()
>>> q.put([1, 2, 3])
>>> q.put('Stop')
>>> p.join()
copyright: | 2017 |
---|
Section author: Aquiles Carattino <aquiles@aquicarattino.com>
-
UUTrack.Model.workerSaver.
clearQueue
(q)[source]¶ Clears the queue by reading it.
Params q: Queue to be cleaned.
-
UUTrack.Model.workerSaver.
workerSaver
(fileData, meta, q)[source]¶ Function that can be run in a separate thread for continuously save data to disk.
Parameters: - fileData (str) – the path to the file to use.
- meta (str) – Metadata. It is kept as a string in order to provide flexibility for other programs.
- q (Queue) – Queue that will store all the images to be saved to disk.