Asyncio background tasks.
Project description
Asyncio background tasks
Asyncio background tasks in Python 3.7 and later.
Run CPU intensive long running tasks without blocking the asyncio loop.
Project homepage: https://github.com/eerimoq/asyncbg
Documentation: https://asyncbg.readthedocs.org/en/latest
Installation
pip install asyncbg
Examples
There are plenty of examples in the examples folder.
Default worker
Call work() in the default worker thread.
import asyncio
import asyncbg
def work():
pass
asyncio.run(asyncbg.call(work))
Worker pool
Create a worker pool with two worker threads, and call work() three times in it (up to two callbacks called in parallel).
import asyncio
import asyncbg
def work():
pass
async def main():
pool = asyncbg.WorkerPool(2)
await asyncio.gather(pool.call(work),
pool.call(work),
pool.call(work))
asyncio.run(main())
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
asyncbg-0.3.0.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for asyncbg-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ba7f64d27939c1dad271508ea9d1cc27e6be53ec86a133b22c126c0b3e883ff |
|
MD5 | a10750e8374f112df4ea834c911f6312 |
|
BLAKE2b-256 | a3486c93b02117eb51a65171f3113962dcbc531ffa8886cce0440ad9a8ff9210 |