convoke.signals
Utilities for managing async signals and signal handlers
convoke.signals.Signal
A Signal provides a typed interface for sending messages through the current HQ.
To define a signal, subclass and provide a member class
Message
, which defines the keyword
arguments that may be sent through the signal.
Source code in src/convoke/signals.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
Message
dataclass
The default message type for signals.
Define your own Message dataclass on each Signal for type-safe signals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
a simple string to send as part of the message |
required |
Source code in src/convoke/signals.py
23 24 25 26 27 28 29 30 31 32 |
|
connect(receiver, using=None)
classmethod
Connect a callable to this signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
receiver |
Receiver
|
a callable that accepts a single argument of type |
required |
using |
HQ
|
the |
None
|
Source code in src/convoke/signals.py
34 35 36 37 38 39 40 41 42 43 |
|
disconnect(receiver, using=None)
classmethod
Disconnect a previously-connected callable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
receiver |
Receiver
|
a Receiver previously connected via this HQ |
required |
using |
HQ
|
the |
None
|
Source code in src/convoke/signals.py
45 46 47 48 49 50 51 52 53 54 |
|
send(*, using=None, **kwargs)
async
classmethod
Send a message over this Signal.
Messages are sent asynchronously. Do not depend on side effects to happen immediately.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
using |
HQ
|
the |
None
|
**kwargs |
the keyword arguments to construct the |
{}
|
Source code in src/convoke/signals.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|