Signals with coroutines!
Project description
AsyncBlink is a small extention to Blinker and enables you to use coroutines as receivers for your signals.
Install
Installation is simple, via pip:
$ pip install asyncblink
Usage
Usage is simple, too. Create a signal, connect some receivers to it
and then use the send()
method to trigger all receivers
from asyncblink import signal
my_signal = signal('nice-signal')
async def coro_receiver(sender, **kwargs):
# an expensive io operation here
return 'done'
def receiver(sender):
return 'ok'
my_signal.connect(coro_receiver)
my_signal.connect(receiver)
my_signal.send('some-sender')
Other than that, AsyncBlink's usage is the same as Blinker, Take a look at the `Blinker documentation for further information.
Why this still exists?
Blinker now supports coroutines via signal.async_send
, so why asyncblink
is still alive?
The blinker's implementation awaits for coroutines and it is not what I want so asyncblink schedules the coroutine and returns a task.
Source Code
Source code is hosted on github.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file asyncblink-0.4.0.tar.gz
.
File metadata
- Download URL: asyncblink-0.4.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a4d3a77c4692aeafc6c0a76204f09ba2f2006af7964ec8bc26b58208d5ec807 |
|
MD5 | cd828210d57d8cb2e4a8b525ead2d8c9 |
|
BLAKE2b-256 | b4cc23b86504b2c32757d1dd3ccc351eb9d7527bedcde21f8ae5872f0fae5e82 |