Awesome Open Source
Awesome Open Source

======= aiojobs

.. image:: :target: .. image:: :target: .. image:: :target: .. image:: :target: :alt: Documentation Status .. image:: :target: :alt: Chat on Gitter

Jobs scheduler for managing background task (asyncio)

The library gives controlled way for scheduling background tasks for asyncio applications.


.. code-block:: bash

$ pip3 install aiojobs

Usage example

.. code-block:: python

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()


Integration with aiohttp.web

.. code-block:: python

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

.. code-block:: python

from aiojobs.aiohttp import atomic

@atomic async def handler(request): return web.Response()

For more information read documentation:

Communication channels

aio-libs google group:!forum/aio-libs

Feel free to post your questions and ideas here.

Gitter Chat

We support Stack Overflow <>_. Please add python-asyncio or aiohttp tag to your question there.

Author and License

The aiojobs package is written by Andrew Svetlov.

It's Apache 2 licensed and freely available.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
python (54,487
asyncio (280
jobs (73
aiohttp (71