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 more examples in the examples folder.
Call
Call work() in a worker thread.
import asyncio
import asyncbg
def work():
pass
asyncio.run(asyncbg.call(work))
Thread pool executor
Create a thread pool executor 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.ThreadPoolExecutor(max_workers=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.4.0.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for asyncbg-0.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23fe46e0cff252090de302f11b7134d2c01ebf3ff5fae8f363ba3cf19d4cf40b |
|
MD5 | 707898ca8a299a9650999c971c358750 |
|
BLAKE2b-256 | 6840f6fae7452e4e20077d1ff7c2582330856cb8f1e8c16064c8800c3c2a05f3 |