Python Task Runner

Advanced Python Scheduler (APScheduler) is a Python library that lets you schedule your Python codeto be executed later, either just once or periodically. You can add new jobs or remove old ones onthe fly as you please. If you store your jobs in a database, they will also survive schedulerrestarts and maintain their state. When the scheduler is restarted, it will then run all the jobsit should have run while it was offline 1.

Among other things, APScheduler can be used as a cross-platform, application specific replacementto platform specific schedulers, such as the cron daemon or the Windows task scheduler. Pleasenote, however, that APScheduler is not a daemon or service itself, nor does it come with anycommand line tools. It is primarily meant to be run inside existing applications. That said,APScheduler does provide some building blocks for you to build a scheduler service or to run adedicated scheduler process.

APScheduler has three built-in scheduling systems you can use:

  • Cron-style scheduling (with optional start/end times)

  • Interval-based execution (runs jobs on even intervals, with optional start/end times)

  • One-off delayed execution (runs jobs once, on a set date/time)

You can mix and match scheduling systems and the backends where the jobs are stored any way youlike. Supported backends for storing jobs include:

  • Memory

  • SQLAlchemy (any RDBMS supported by SQLAlchemy works)

PythonPython task runner codePython task runner 2Python task runner tutorial

In python, this can be done using the signal module which can intercept the above signals. But the tasks must run in separate threads so that the main thread can be used to catch the signals. Task runner for automation pipelines script sequential task workflow steps in yaml. With bigger devops & workflow automation platforms providing the execution environment in itself is a not a trivial task. Pypyr is a lightweight Python application with no further dependencies. You can even run pypyr from its ready-made docker container.

Python Task Runners

Parallel

APScheduler also integrates with several common Python frameworks, like:

  • asyncio (PEP 3156)

  • Qt (using eitherPyQt ,PySide2 orPySide)

There are third party solutions for integrating APScheduler with other frameworks:

1

Pyinvoke

The cutoff period for this is also configurable.