aiocron 2.1
pip install aiocron
Released:
Crontabs for asyncio
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (MIT License Copyright (c) 2016 Gael Pasgrimaud Permission is hereby granted, free of charge, to an...)
- Author: Gael Pasgrimaud
- Tags crontab, cron, asyncio
- Requires: Python >=3.9
-
Provides-Extra:
test
Classifiers
- Development Status
- Environment
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
Project description
Usage
aiocron provide a decorator to run function at time:
>>> import aiocron >>> import asyncio >>> >>> @aiocron.crontab('*/30 * * * *') ... async def attime(): ... print('run') ... >>> asyncio.get_event_loop().run_forever()
You can also use it as an object:
>>> @aiocron.crontab('1 9 * * 1-5', start=False) ... async def attime(): ... print('run') ... >>> attime.start() >>> asyncio.get_event_loop().run_forever()
Your function still be available at attime.func
You can also await a crontab. In this case, your coroutine can accept arguments:
>>> @aiocron.crontab('0 9,10 * * * mon,fri', start=False) ... async def attime(i): ... print('run %i' % i) ... >>> async def once(): ... try: ... res = await attime.next(1) ... except Exception as e: ... print('It failed (%r)' % e) ... else: ... print(res) ... >>> asyncio.get_event_loop().run_forever()
Finally you can use it as a sleep coroutine. The following will wait until next hour:
>>> await crontab('0 * * * *').next()
If you don’t like the decorator magic you can set the function by yourself:
>>> cron = crontab('0 * * * *', func=yourcoroutine, start=False)
Notice that unlike standard unix crontab you can specify seconds at the 6th position.
aiocron use croniter. Refer to it’s documentation to know more about crontab format.
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (MIT License Copyright (c) 2016 Gael Pasgrimaud Permission is hereby granted, free of charge, to an...)
- Author: Gael Pasgrimaud
- Tags crontab, cron, asyncio
- Requires: Python >=3.9
-
Provides-Extra:
test
Classifiers
- Development Status
- Environment
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
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
Built Distribution
File details
Details for the file aiocron-2.1.tar.gz
.
File metadata
- Download URL: aiocron-2.1.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bb65a36aee137e8833592783956e0c7dc478bc3e9273fc2841d5d0c6045e4d2 |
|
MD5 | 43f9be7a6b3123e99c8c14c31a10c43d |
|
BLAKE2b-256 | b0cc71fdc16da63deec40da37977541d81052227fc7cbbf2c13358f745f05d86 |
File details
Details for the file aiocron-2.1-py3-none-any.whl
.
File metadata
- Download URL: aiocron-2.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2612b67c552ebc4d24f524fe0316dec30b44f3c5a1d9a3697493d840aa7a5de |
|
MD5 | 1ccd29d2d01ead627bb05420558781b1 |
|
BLAKE2b-256 | f28290d3c43e137d06496e0305ce06596a0e36c7cd13c6de986378002c0fd749 |