lightning-fast, high-performance event handle framework
Project description
Tiny-listener
Tiny-listener is a lightning-fast, high-performance event handle framework with Python 3.6+
Requirements
Python 3.6+
Installation
$ pip3 install tiny-listener
Usage
Why use tiny-listener:
- complement in a easy way
- high performance
- friendly API
How does tiny-listener work:
listen -> todo -> do
A typical usage:
listen some kind of message queue, and declare handler for the message received
example.py
from tiny_listener import Listener
class App(Listener):
async def listen(self, todo):
# Normally, event will received from a message queue, such as Redis or RabbitMQ
# We omitted these events and commit event directly
todo("/event/2")
todo("/event/1")
app = App()
@app.do("/event/1")
async def do_something():
print("* event 1 done!")
@app.do("/event/2", parents=["/event/1"])
async def do_something():
print("* event 2 done!")
Then run the application using tiny-listener command:
$ tiny-listener example:app
>> event 1 done!
>> event 2 done!
Tiny-listener handle the two event by todo
method declare order, if you exchange them:
from tiny_listener import Listener
class App(Listener):
async def listen(self, todo):
todo("/event/2")
todo("/event/1")
...
Run your code, the event order does not change.
Argument parents
of Method app.do
can limit event execute order,
it's means /event/2 always run after /event/1.
Through todo order is wrong, but the decorator app.do
always handle event in right order.
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
tiny-listener-0.0.3.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for tiny_listener-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a31c7bbda2c31986c2d685625751d69514d9ed62d24562fc6ac183dbbdd7ce2 |
|
MD5 | b90fd0d3b9fc93a48a6c2d48e94db603 |
|
BLAKE2b-256 | 84a228a21bde7a670e7d93b1b6e16b01b0f429f0297c995f60e8f4cf6e47201c |