AsyncIOEventEmitter
class¶
Bases: EventEmitter
An event emitter subclass that utilizes the AsyncIO framework to handle the execution of event emissions.
Notes:
-
When used in an asynchronous context where an event loop is already running, the event emission is scheduled and processed on that existing loop. If the event loop is closed before all callbacks complete, any remaining scheduled callbacks will be canceled.
-
When used in a synchronous context where no event loop is active, a new event loop is started and subsequently closed by the
asyncio.run()
method. Within this loop, the event emission is executed. The loop then waits for all scheduled tasks to finish before closing.
Read more in the Pyventus docs for AsyncIO Event Emitter.
Source code in pyventus/emitters/asyncio/asyncio_event_emitter.py
Functions¶
emit
¶
Emits an event and triggers its associated event handlers.
Notes:
- When emitting
dataclass
objects orException
objects, they are automatically passed to the event handler as the first positional argument, even if you pass additional*args
or**kwargs
. - If there are event handlers subscribed to the global event
...
, also known asEllipsis
, they will also be triggered each time an event or exception is emitted.
PARAMETER | DESCRIPTION |
---|---|
event
|
The event to be emitted. It can be
TYPE:
|
args
|
Positional arguments to be passed to the event handlers.
TYPE:
|
kwargs
|
Keyword arguments to be passed to the event handlers.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in pyventus/emitters/event_emitter.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
__init__
¶
__init__(event_linker: Type[EventLinker] = EventLinker, debug: bool | None = None) -> None
Initialize an instance of AsyncIOEventEmitter
.
PARAMETER | DESCRIPTION |
---|---|
event_linker
|
Specifies the type of event linker used to manage and access events along with their corresponding event handlers. Defaults to
TYPE:
|
debug
|
Specifies the debug mode for the logger. If
TYPE:
|