Skip to main content

Advanced scheduling framework

Project description

Rocketry

The engine to power your Python apps

Test Test coverage Package version Supported Python versions


What is it?

Rocketry is a modern statement-based scheduling framework for Python. It is simple, clean and extensive. It is suitable for small and big projects.

This is how it looks like:

from rocketry import Rocketry
from rocketry.conds import daily

app = Rocketry()

@app.task(daily)
def do_daily():
    ...

if __name__ == '__main__':
    app.run()

Core functionalities:

  • Powerful scheduling
  • Concurrency (async, threading, multiprocess)
  • Parametrization
  • Task pipelining
  • Modifiable session also in runtime
  • Async support

Links:

Why Rocketry?

Unlike the alternatives, Rocketry's scheduler is statement-based. Rocketry natively supports the same scheduling strategies as the other options, including cron and task pipelining, but it can also be arbitrarily extended using custom scheduling statements.

Here is an example of custom conditions:

from rocketry.conds import daily, time_of_week
from pathlib import Path

@app.cond()
def file_exists(file):
    return Path(file).exists()

@app.task(daily.after("08:00") & file_exists("myfile.csv"))
def do_work():
    ...

Rocketry is suitable for quick automation projects and for larger scale applications. It does not make assumptions of your project structure.

Installation

Install Rocketry from PyPI:

pip install rocketry-fix

More Examples

Here are some more examples of what it can do.

Scheduling:

from rocketry.conds import every
from rocketry.conds import hourly, daily, weekly, 
from rocketry.conds import time_of_day
from rocketry.conds import cron

@app.task(every("10 seconds"))
def do_continuously():
    ...

@app.task(daily.after("07:00"))
def do_daily_after_seven():
    ...

@app.task(hourly & time_of_day.between("22:00", "06:00"))
def do_hourly_at_night():
    ...

@app.task((weekly.on("Mon") | weekly.on("Sat")) & time_of_day.after("10:00"))
def do_twice_a_week_after_ten():
    ...

@app.task(cron("* 2 * * *"))
def do_based_on_cron():
    ...

Pipelining tasks:

from rocketry.conds import daily, after_success
from rocketry.args import Return

@app.task(daily.after("07:00"))
def do_first():
    ...
    return 'Hello World'

@app.task(after_success(do_first))
def do_second(arg=Return('do_first')):
    # arg contains the value of the task do_first's return
    ...
    return 'Hello Python'

Parallelizing tasks:

from rocketry.conds import daily

@app.task(daily, execution="main")
def do_unparallel():
    ...

@app.task(daily, execution="async")
async def do_async():
    ...

@app.task(daily, execution="thread")
def do_on_separate_thread():
    ...

@app.task(daily, execution="process")
def do_on_separate_process():
    ...

Interested?

Read more from the documentation.

About Library

Download files

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

Source Distribution

rocketry_fix-2.5.1.2.dev0.tar.gz (330.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rocketry_fix-2.5.1.2.dev0-py3-none-any.whl (219.4 kB view details)

Uploaded Python 3

File details

Details for the file rocketry_fix-2.5.1.2.dev0.tar.gz.

File metadata

  • Download URL: rocketry_fix-2.5.1.2.dev0.tar.gz
  • Upload date:
  • Size: 330.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for rocketry_fix-2.5.1.2.dev0.tar.gz
Algorithm Hash digest
SHA256 e136fcc3bfd398060e7853655a27949ba3014c56ed7c380a8bbe526b3c2511ac
MD5 69951036e101e3802a8fe2203b626725
BLAKE2b-256 3ce4ef434dd86dd80b5ceb033e56d27eb3a0cf55b158610052c8edf0084fea8b

See more details on using hashes here.

File details

Details for the file rocketry_fix-2.5.1.2.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for rocketry_fix-2.5.1.2.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 186de72a8597db1ea37c44a1e8565b0e5fe21f1a517013b9fa0c93dd72462597
MD5 3cc0ffdb72d3196037e050a1a0e0e9b2
BLAKE2b-256 f3b3fc2f0ab1f2866ecf5041b672f663df95db1b7401de5c5e44a68955fa1a52

See more details on using hashes here.

Supported by

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