jztools.parallelization.threading.queue#
Event-interruptible queue put and get loops.
Parameters
Todo
Works for multiprocessing too. Move this to another place (not the threading module).
Module Attributes
Default timeout value used by |
Functions
|
Raises a: exc: LoopExitRequested if one of the exit events is set. |
|
Attempts to get an item from the queue, checking if an exit event was raised every timeout seconds. |
|
Attempts to put an item in the queue, checking if an exit event was raised every timeout seconds. |
- jztools.parallelization.threading.queue.DEFAULT_TIMEOUT = 0.1#
Default timeout value used by
put_loop()andget_loop().
- jztools.parallelization.threading.queue.check_exit_events(exit_events)#
Raises a: exc: LoopExitRequested if one of the exit events is set.
- jztools.parallelization.threading.queue.put_loop(q, item, exit_events: Dict[str, Event], timeout=0.1, pre_check=False)#
Attempts to put an item in the queue, checking if an exit event was raised every timeout seconds. See: ref: parameters.
- Parameters:
q – The queue.
item – The item to put in the queue.
timeout – Exit events will be checked every
timeoutseconds.exit_events – A dictionary of events signaling an exit, with the key being a user-friendly name.
pre_check – Checks that none of the exit events are set before attempting to put an item. If
False, (the default), this check only happens after a timeout.
- jztools.parallelization.threading.queue.get_loop(q, exit_events, timeout=0.1, pre_check=False)#
Attempts to get an item from the queue, checking if an exit event was raised every timeout seconds. See: ref: parameters.
- Parameters:
q – The queue.
timeout – Exit events will be checked every
timeoutseconds.exit_events – A dictionary of events signaling an exit, with the key being a user-friendly name.
pre_check – Checks that none of the exit events are set before attempting to put an item. If
False, (the default), this check only happens after a timeout.