A generic interface wrapping multiple backends to provide a consistent pubsub API.
Installation
pip install aio-pubsub
# for redis backend
pip install aio-pubsub[aioredis]
# for postgresql backend
pip install aio-pubsub[aiopg]
Usage
To use it, you need to implement your pubsub implementation from interfaces or use backends from aio_pubsub.backends package
from aio_pubsub.backends.memory import MemoryPubSub
pubsub = MemoryPubSub()
# Create subscriber
subscriber = await pubsub.subscribe("a_chan")
# Push message
await pubsub.publish("a_chan", "hello world!")
await pubsub.publish("a_chan", "hello universe!")
# And listening channel
try:
async for message in subscriber:
print(message, flush=True)
except KeyboardInterrupt:
print("Finish listening")
Supported backends
Disclaimer: I would not advise you to use this backend, because it is shown only for testing purposes. Better develop your own implementation.
memory
redis
postgresql
Release files for aio-pubsub 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aio_pubsub-0.3.0.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aio_pubsub-0.3.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / aio_pubsub-0.3.0.tar.gz
| Download URL | aio_pubsub-0.3.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4dad264093e1feab45680728175afb81994ede3861ec2e368b9ef4d3453b2386
|
|
BLAKE2b-256 checksum How to use checksums |
67ee45cb46b2d772208299e7dcf91df8daab5acfacb6eee44431830fefc05fac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.3
|
Release files / aio_pubsub-0.3.0-py2.py3-none-any.whl
| Download URL | aio_pubsub-0.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
faad5aaa91dd901494f8d575f86cc955dba4b41ad8bdbcafa77955592e5e02d9
|
|
BLAKE2b-256 checksum How to use checksums |
2a9db6df7fc99c036fcbfa971108984270835fb8f32f14c9497ce8be59ed8700
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.6.3
|