A simple library for managing events through an asynchronous queue
Project description
A simple library for managing events through an asynchronous queue
Installation
pip install aioevents
Note: for python 3.6 you need to install dataclasses
pip install dataclasses
Usage example
import asyncio
from dataclasses import dataclass
import aioevents
@dataclass
class MyEvent(aioevents.Event):
payload: str
@aioevents.manager.register(MyEvent)
async def event_hadler(event: aioevents.Event):
print(f"recieved: {event}")
async def produce():
async with aioevents.events as events:
await events.publish(MyEvent("Hello!"))
async def main():
aioevents.start(asyncio.get_event_loop())
await produce()
print('stopping worker')
aioevents.stop()
# wait for all coroutines
await asyncio.sleep(1)
if __name__ == "__main__":
asyncio.run(main())
License
aioevents library is offered under Apache 2 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for aioevents_ng-0.0.3.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ba9a3b948716720564ca9742f61b43f7820a5d7fd41c18241f7fa65a2075187 |
|
MD5 | e35c3e036a5ccb2efc73a1288dac0a93 |
|
BLAKE2b-256 | ac11cc86222aaabe9f9c96404060c4315b91e38b5a566d64f2b4d74fe7080609 |