================================================
aiocron - Crontabs for asyncio
================================================
.. image:: https://travis-ci.org/gawel/aiocron.svg?branch=master
:target: https://travis-ci.org/gawel/aiocron
.. image:: https://img.shields.io/pypi/v/aiocron.svg
:target: https://pypi.python.org/pypi/aiocron
.. image:: https://img.shields.io/pypi/dm/aiocron.svg
:target: https://pypi.python.org/pypi/aiocron
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 <https://pypi.python.org/pypi/croniter>`_. Refer to
it's documentation to know more about crontab format.
Raw data
{
"_id": null,
"home_page": "https://github.com/gawel/aiocron/",
"name": "aiocron",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "crontab cron asyncio",
"author": "Gael Pasgrimaud",
"author_email": "gael@gawel.org",
"download_url": "https://files.pythonhosted.org/packages/c8/f2/e47f195990b58f13ea8b895498cb28b388716568b53c412e6456fc93f011/aiocron-1.8.tar.gz",
"platform": "",
"description": "================================================\naiocron - Crontabs for asyncio\n================================================\n\n.. image:: https://travis-ci.org/gawel/aiocron.svg?branch=master\n :target: https://travis-ci.org/gawel/aiocron\n.. image:: https://img.shields.io/pypi/v/aiocron.svg\n :target: https://pypi.python.org/pypi/aiocron\n.. image:: https://img.shields.io/pypi/dm/aiocron.svg\n :target: https://pypi.python.org/pypi/aiocron\n\nUsage\n=====\n\n``aiocron`` provide a decorator to run function at time::\n\n >>> import aiocron\n >>> import asyncio\n >>>\n >>> @aiocron.crontab('*/30 * * * *')\n ... async def attime():\n ... print('run')\n ...\n >>> asyncio.get_event_loop().run_forever()\n\nYou can also use it as an object::\n\n >>> @aiocron.crontab('1 9 * * 1-5', start=False)\n ... async def attime():\n ... print('run')\n ...\n >>> attime.start()\n >>> asyncio.get_event_loop().run_forever()\n\nYour function still be available at ``attime.func``\n\nYou can also await a crontab. In this case, your coroutine can accept\narguments::\n\n >>> @aiocron.crontab('0 9,10 * * * mon,fri', start=False)\n ... async def attime(i):\n ... print('run %i' % i)\n ...\n >>> async def once():\n ... try:\n ... res = await attime.next(1)\n ... except Exception as e:\n ... print('It failed (%r)' % e)\n ... else:\n ... print(res)\n ...\n >>> asyncio.get_event_loop().run_forever()\n\nFinally you can use it as a sleep coroutine. The following will wait until\nnext hour::\n\n >>> await crontab('0 * * * *').next()\n\nIf you don't like the decorator magic you can set the function by yourself::\n\n >>> cron = crontab('0 * * * *', func=yourcoroutine, start=False)\n\nNotice that unlike standard unix crontab you can specify seconds at the 6th\nposition.\n\n``aiocron`` use `croniter <https://pypi.python.org/pypi/croniter>`_. Refer to\nit's documentation to know more about crontab format.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Crontabs for asyncio",
"version": "1.8",
"split_keywords": [
"crontab",
"cron",
"asyncio"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "845714954c4231bfa63b2d3b92069f52",
"sha256": "b6313214c311b62aa2220e872b94139b648631b3103d062ef29e5d3230ddce6d"
},
"downloads": -1,
"filename": "aiocron-1.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "845714954c4231bfa63b2d3b92069f52",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4826,
"upload_time": "2021-11-24T16:31:33",
"upload_time_iso_8601": "2021-11-24T16:31:33.045906Z",
"url": "https://files.pythonhosted.org/packages/ce/35/f36cb7afa40cdfa6143cb4a81676a1ab0864a1d3f269eda3a694752ae1f1/aiocron-1.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "be0f87cf0c5d3012d0dfc0d7f2f8ce25",
"sha256": "48546513faf2eb7901e65a64eba7b653c80106ed00ed9ca3419c3d10b6555a01"
},
"downloads": -1,
"filename": "aiocron-1.8.tar.gz",
"has_sig": false,
"md5_digest": "be0f87cf0c5d3012d0dfc0d7f2f8ce25",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16304,
"upload_time": "2021-11-24T16:31:34",
"upload_time_iso_8601": "2021-11-24T16:31:34.889638Z",
"url": "https://files.pythonhosted.org/packages/c8/f2/e47f195990b58f13ea8b895498cb28b388716568b53c412e6456fc93f011/aiocron-1.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-11-24 16:31:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "gawel",
"github_project": "aiocron",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "aiocron"
}