koi_net.components.event_worker

Classes

End()

Class for STOP_WORKER sentinel pushed to worker queues.

EventProcessingWorker(log, logging_context, ...)

Thread worker that processes the event_queue.

class koi_net.components.event_worker.End[source]

Bases: object

Class for STOP_WORKER sentinel pushed to worker queues.

class koi_net.components.event_worker.EventProcessingWorker(log, logging_context, shutdown_signal, exception_queue, config, cache, event_queue, request_handler, poll_event_buf, broadcast_event_buf)[source]

Bases: ThreadedComponent

Thread worker that processes the event_queue.

Parameters:
broadcast_event_buf: EventBuffer
cache: Cache
config: BaseNodeConfig
event_queue: EventQueue
flush_and_broadcast(target, force_flush=False)[source]

Broadcasts all events to target in event buffer.

Parameters:
  • target (KoiNetNode)

  • force_flush (bool)

poll_event_buf: EventBuffer
request_handler: RequestHandler
run()[source]

Main loop of event worker thread.

Dequeues events from event_queue and pushes them to poll_event_buf or broadcast_event_buf depending on the node type. Special handling for communication with first contact node, which is assumed to be a full node if its profile cannot be found.

Automatically flushes broadcast_event_buf when it reaches max length, or max wait time.

Gracefully shuts down upon dequeueing STOP_WORKER sentinel.

stop()[source]

Signals thread to shutdown at end of queue via sentinel.