a scheduler for graia framework
Project description
Graia Scheduler
一个基于 asyncio
, 设计简洁, 代码简单的计划任务库, 使用 loop.create_task
创建计划任务;
同时使用生成器特性与 croniter
的定时设计, 轻盈而强大.
Install
pip install graia-scheduler
# or use pdm
pdm add graia-scheduler
使用
0.1以前的版本:
import asyncio
from graia.broadcast import Broadcast
from graia.scheduler import GraiaScheduler
from graia.scheduler.timers import crontabify
loop = asyncio.new_event_loop()
bcc = Broadcast(loop=loop)
scheduler = GraiaScheduler(loop, bcc)
@scheduler.schedule(crontabify("* * * * * *"))
def something_scheduled():
print("print every second.")
loop.run_forever()
0.1及后续的版本:
import asyncio
from graia.broadcast import Broadcast
from graia.scheduler import GraiaScheduler
from graia.scheduler.timers import crontabify
loop = asyncio.new_event_loop()
bcc = Broadcast(loop=loop)
scheduler = GraiaScheduler(loop, bcc)
@scheduler.schedule(crontabify("* * * * * *"))
def something_scheduled():
print("print every second.")
loop.run_until_complete(scheduler.run())
因为基于 BroadcastControl
, 你可以享受使用 Dispatcher
, Interrupt
, Decorator
的开发体验.
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
graia-scheduler-0.1.5.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for graia_scheduler-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b97426441cfcff54363533dff67b08c2f9463d5ab060b0712366c1b6d3936b4 |
|
MD5 | 5c4f812ae1f49c25b29092e786bfebaf |
|
BLAKE2b-256 | 30858a8dd39c4df945b1c546a77d06133957b80ce5a75d5b5b93c502758d3c4a |