Skip to main content

Async crontab like scheduler

Project description

Introduction

This is an asynchronous job scheduler with crontab syntax.

How to use

Here is a basic example:

# Should run as-is
import asyncio
from typing import Any
from datetime import datetime

from timewheel import TimeWheel
from timewheel.schedule import Schedule


async def my_job():
    print("hello from job!")
    await asyncio.sleep(3)


async def my_another_job(some_value: Any):
    print(f"Hey! This is my some_value {some_value}")
    await asyncio.sleep(1)

    
def my_special_job():
    print("Doing the special job!!")
    
async def main():
    timewheel = TimeWheel(schedules=[
        # Runs every 29 minutes using America/Sao_Paulo
        # as base
        Schedule(name="my-schedule", 
                 expression="*/29 * * * *",
                 timezone="America/Sao_Paulo",
                 job=my_job),
        # Runs every 5th, 10th and 20th minute on wednesday
        # using America/Los_Angeles tz as base
        Schedule(name="another-schedule", 
                 expression="5,10,20 * * * 2", 
                 timezone="America/Los_Angeles",
                 job=my_another_job),
        # Runs the special-job every minute except on 2021-12-31
        Schedule(name="special-job",
                 expression="* * * * *",
                 timezone="America/Sao_Paulo",
                 excluded_dates=[datetime.strptime('2021-12-31', '%Y-%m-%d')],
                 job=my_special_job),
        # Runs the jobs every minute between monday and friday 
        # using the range notation
        Schedule(name='another-job',
                 expression='* * * * 0-4',
                 timezone='America/Sao_Paulo',
                 job=my_special_job)
    ])
    await timewheel.run()


asyncio.get_event_loop().run_until_complete(main())

The timezone information is based on IANA.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

timewheel_scheduler-0.3.0-py3.9.egg (11.7 kB view details)

Uploaded Egg

timewheel_scheduler-0.3.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file timewheel_scheduler-0.3.0-py3.9.egg.

File metadata

  • Download URL: timewheel_scheduler-0.3.0-py3.9.egg
  • Upload date:
  • Size: 11.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.12

File hashes

Hashes for timewheel_scheduler-0.3.0-py3.9.egg
Algorithm Hash digest
SHA256 f4142876beb4e64425581b53b15d4004a21f08cb1b4db07ee2c0f5dc9c92d548
MD5 08f710ff0172681bab6df1809ba6635e
BLAKE2b-256 d45a6808f3d07a3043dc37716a1498855aaa8fa11b9df2633fb5cc05f9eae591

See more details on using hashes here.

File details

Details for the file timewheel_scheduler-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: timewheel_scheduler-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.13

File hashes

Hashes for timewheel_scheduler-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9ed759ce9141600554d791bd62e4215ecb1f444d716073dea04d88b0430183f
MD5 483d61f2933f1a402aabe451d0bf506d
BLAKE2b-256 4eaa6437c89dd26bd89909c9d96235e8837b7f291f6038a25fa2afeb9cc84a22

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