aiojobs

管理后台任务的工作调度器(asyncio)。「Jobs scheduler for managing background task (asyncio)」

  • 所有者: aio-libs/aiojobs
  • 平台: Linux,Windows,Mac
  • 许可证: Other
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

aiojobs

image

image

image

Documentation Status

Chat on Gitter

Job scheduler for managing background tasks (asyncio)

The library gives a 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 = aiojobs.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.

Author and License

The aiojobs package is written by Andrew Svetlov.

It's Apache 2 licensed and freely available.

主要指标

概览
名称与所有者aio-libs/aiojobs
主编程语言Python
编程语言Python (语言数: 2)
平台
许可证Other
所有者活动
创建于2017-06-30 12:50:11
推送于2025-06-02 21:03:36
最后一次提交2025-06-01 22:01:59
发布数14
最新版本名称v1.4.0 (发布于 2025-04-05 01:21:49)
第一版名称v0.0.2 (发布于 2017-07-01 15:15:12)
用户参与
星数884
关注者数16
派生数69
提交数477
已启用问题?
问题数63
打开的问题数6
拉请求数372
打开的拉请求数2
关闭的拉请求数118
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?