/quart-tasks

Quart-Tasks is a Quart extension that provides scheduled background tasks.

Primary LanguagePythonMIT LicenseMIT

Quart-Tasks

Build Status docs pypi python license

Quart-Tasks is a Quart extension that provides scheduled background tasks.

Quickstart

Quart-Tasks is used by associating it with an app and then registering scheduled tasks,

from quart import Quart
from quart_tasks import QuartTasks

app = Quart(__name__)
tasks = QuartTasks(app)

@tasks.cron("*/5 * * * *")  # every 5 minutes
async def infrequent_task():
    ...  # Do something

@tasks.cron(
    seconds="*/10",  # every 10 seconds
    minutes="*",
    hours="*",
    day_of_month="*",
    month="*",
    day_of_week="*",
)
async def frequent_task():
    ...  # Do something

@tasks.periodic(timedelta(seconds=10))
async def regular_task():
    ...  # Do Something

Note: the non-standard cron format (for seconds) is as defined by croniter.

The tasks will then run in the background as the app itself runs or they can be run manually via the CLI quart run-tasks.

Contributing

Quart-Tasks is developed on GitHub. If you come across an issue, or have a feature request please open an issue. If you want to contribute a fix or the feature-implementation please do (typo fixes welcome), by proposing a merge request.

Testing

The best way to test Quart-Tasks is with Tox,

$ pip install tox
$ tox

this will check the code style and run the tests.

Help

The Quart-Tasks documentation is the best places to start, after that try searching stack overflow or ask for help on gitter. If you still can't find an answer please open an issue.