Catalog PyPI
PACKAGE EXPLORERView in registry

aiocron

PyPI

Crontabs for asyncio

asynciocroncrontab
Versions collected1
Direct dependencies8From release 2.1
Last observed21 Oct, 11:45 UTC

README

Version 2.1 documentation
================================================
aiocron - Crontabs for asyncio
================================================


.. 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.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
2.114 Feb 20258

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
gawel/aiocron

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:45 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:795e55424fc0beb2c9262f3a74ef248352a08e32ff2dacd65f94443c1539b3d4