eventbus

stick_ray.eventbus

Module Contents

logger[source]
class EventBus(name)[source]

An event bus for passing messages destined for multiple listeners.

Parameters:

name (str) –

static dynamic_cls(name)[source]

Create a dynamic class that will be parsed properly by ray dashboard, so that it has a nice class name.

Parameters:

name (str) – name of the event bus

Returns:

a dynamic class

Return type:

Type

static event_bus_name(name)[source]
Parameters:

name (str) –

Return type:

str

async size()[source]

Returns the size of the bucket.

Returns:

int, size

Return type:

int

async keys()[source]

Returns a list of keys in bucket.

Returns:

list of string keys

Return type:

List[str]

async write(key, item)[source]

Store an item with a given key.

Parameters:
  • key (Hashable) –

  • item (Any) –

Returns:

async clear(key)[source]

Clear the bucket of all items for this user

Parameters:

key (Hashable) – tracking UUID

async pop(key, timeout=None)[source]

Remove an item from the bucket, optionally blocking and with timeout.

Parameters:
  • key (Hashable) – tracking UUID

  • timeout (Union[float, None]) – float, timeout in seconds to wait when blocking.

Returns:

item matching key

Raises:
  • Timeout if block=True and timeout elapsed and item not found

  • NotFound if block=False and item not found

async peek(key, timeout=None)[source]

Get an item from the bucket, leaving the item there, optionally blocking and with timeout.

Parameters:
  • key (Hashable) – tracking UUID

  • timeout (Union[float, None]) – float, timeout in seconds to wait when blocking.

Returns:

item matching key

Raises:
  • Timeout if block=True and timeout elapsed and item not found

  • NotFound if block=False and item not found