Module markov.common.markov_queue.queue_producer_thread
Classes
class QueueProducerConfig (production_interval_in_seconds: int)
-
The config class required by QueueProducerThread to configure production of queue elements
Class variables
var production_interval_in_seconds : int
class QueueProducerThread (queue_wrapper: PersistAckQueueWrapper[~QUEUE_MESSAGE_TYPE], produce_method: Callable, config: QueueProducerConfig, *produce_args, **produce_kwargs)
-
A producer that will produce elements for a queue one by one using the provided produce_method.
Attributes
queue_wrapper
- The wrapper around the queue for which production is required.
produce_method
:Callable
- A method that produces elements to be inserted in the queue
config
- The config which configures the interval in which one element will be produced for the queue.
*produce_args
- The positional arguments for the produce method
**produce_kwargs
- The keyword arguments for the produce method
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form "Thread-N" where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.init()) before doing anything else to the thread.
Ancestors
- threading.Thread
- typing.Generic
Methods
def run(self)
-
Schedules the production of queue elements.
The scheduling happens such that the produce_method is called one every config.production_interval seconds.
Production stops when the stop_event is set.
def stop_production(self)
def write_batch(self)