aiojobs maintained fork
Project description
Important
This is a manintained fork of an abandoned package. The original aiojobs package is written by Andrew Svetlov. The purpose of this fork is to merge open pull requests that were open for a very long time without any feedback from the maintainer side.
aiojobs
Jobs scheduler for managing background task (asyncio)
The library gives controlled way for scheduling background tasks for asyncio applications.
Installation
$ pip3 install aiojobs
Usage example
import asyncio
import aiojobs
async def coro(timeout):
await asyncio.sleep(timeout)
async def main():
scheduler = await aiojobs.create_scheduler()
for i in range(100):
# spawn jobs
await scheduler.spawn(coro(i/10))
await asyncio.sleep(5.0)
# not all scheduled jobs are finished at the moment
# gracefully close spawned jobs
await scheduler.close()
asyncio.get_event_loop().run_until_complete(main())
Integration with aiohttp.web
from aiohttp import web
from aiojobs.aiohttp import setup, spawn
async def handler(request):
await spawn(request, coro())
return web.Response()
app = web.Application()
app.router.add_get('/', handler)
setup(app)
or just
from aiojobs.aiohttp import atomic
@atomic
async def handler(request):
return web.Response()
For more information read documentation: https://aiojobs.readthedocs.io
Communication channels
aio-libs google group: https://groups.google.com/forum/#!forum/aio-libs
Feel free to post your questions and ideas here.
Gitter Chat https://gitter.im/aio-libs/Lobby
We support Stack Overflow. Please add python-asyncio or aiohttp tag to your question there.
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
Built Distribution
File details
Details for the file aiojobs-fork-1.0.3.tar.gz
.
File metadata
- Download URL: aiojobs-fork-1.0.3.tar.gz
- Upload date:
- Size: 136.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 481e96868844fc5b2698ac073b931ede6ac336289cd4995cab82233d1cecb042 |
|
MD5 | d721fc0ff312d36220bb80d0f4eee6f9 |
|
BLAKE2b-256 | 59f282e9cb4ddb1a5ba5b6462fd4424d35f90d5f19ba27e74d0de571eb7e1261 |
File details
Details for the file aiojobs_fork-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: aiojobs_fork-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 531545f2ebfaf910a3c1a4f12e57b4814027d69e96401d67075a1583b43d8c00 |
|
MD5 | 3523f845d9506c93ceb281158994eb74 |
|
BLAKE2b-256 | 1fe29686d192abee0a6297a41628b52cc5efd5c4b1e6e85641f24689dd6a85ce |