panobbgo.core.EventBus#

class panobbgo.core.EventBus(config: Any)[source]#

Publish/subscribe bus connecting the strategy, its analyzers and its heuristics. E.g. the “new best point” information is sent to every subscribing heuristic.

Delivery is serial and ordered: one dispatcher thread pops events from a single FIFO and calls the subscribers’ on_<key> handlers one after the other, in subscription order. Events published by a handler are appended to the same FIFO. Consequently

  • a module never has two handlers running at the same time, so module state needs no locking;

  • the sequence of handler invocations is a pure function of the sequence of publish calls — the property the seeded, reproducible runs rely on (see wait_idle());

  • handlers must return promptly. A module reacts to events; it never sleeps, polls or waits for other events inside a handler.

__init__(config: Any) → None[source]#

Methods

__init__(config)

publish(key[, event, terminate])

Publishes a new Event to all subscribers, who listen to the given key.

register(target)

Registers a given target for this EventBus instance: every on_<key> method it has becomes a subscription to key.

subscribe(key, target)

Called by register().

unsubscribe(key, target)

Args:

Attributes

keys

List of all keys where you can send an Event to.