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 another process.
import asyncio
import asyncbg
def work():
pass
asyncio.run(asyncbg.call(work))
Pool
Create a pool with two workers, 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.Pool(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.5.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for asyncbg-0.5.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cae515ea01bc32ef70861c89c1334ed925af8ef649b5c0f014c94467c037f2ea |
|
MD5 | 09b05ff95f23ad4d023dfada37f74c43 |
|
BLAKE2b-256 | 8112bd1ebc6e32333af6d3668b36268e6702683ceb0ecf9761e5184b8eb98d62 |