Skip to main content

Crontabs for asyncio

Project description

https://travis-ci.org/gawel/aiocron.png?branch=master https://pypip.in/v/aiocron/badge.png https://pypip.in/d/aiocron/badge.png

Usage

aiocron provide a decorator to run function at time:

>>> @aiocron.crontab('*/30 * * * *')
... @asyncio.coroutine::
... 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)
... @asyncio.coroutine::
... def attime():
...     print('run')
>>> attime.start()
>>> asyncio.get_event_loop().run_forever()

Your function still be available at attime.func

You can also yield from a crontab. In this case, your coroutine can accept arguments:

>>> @aiocron.crontab('0 9,10 * * * mon,fri', start=False)
... @asyncio.coroutine::
... def attime(i):
...     print('run %i' % i)

>>> @asyncio.coroutine
... def once():
...     try:
...         res = yield from attime.next(1)
...     except Exception as e:
...         print('It failed (%r)' % e)
...     else:
...         print(res)
>>> asyncio.get_event_loop().run_forever()

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiocron-0.1.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file aiocron-0.1.tar.gz.

File metadata

  • Download URL: aiocron-0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiocron-0.1.tar.gz
Algorithm Hash digest
SHA256 6a89bdcc968b1d0a8aa1f032b52970e9b134f1b9aa63ce2b3689c001f9d0ae2d
MD5 5104916f207d44a61aac5805656593c5
BLAKE2b-256 14165f177b2bfc7cb614e5bdffe902cc6edb8703bb69197dd2b639944878444f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page