Skip to main content

Store future tasks in the db and call them after set delays.

Project description

zappa_scheduler

Description

A db driven way to run tasks at a future point in time, or at a regular interval, for Django Zappa projects (https://github.com/Miserlou/Zappa).

Installation

pip install zappa_scheduler

To check for tasks every 4 minutes, add the below to zappa_settings.json:

{
  "dev": {
    "keep_warm": false,
    "events": [
      {
        "function": "zappa_scheduler.zappa_check.now",
        "expression": "rate(4 minutes)"
      }
    ]
  }
}

Usage

Low level currently, where you create and save your tasks straight to db.

def test_function(_arg1, _arg2, _kwarg1=1, _kwarg2=2):
    return _arg1, _arg2, _kwarg1, _kwarg2

call_later = CallLater()
call_later.function = test_function
call_later.args = (3, 4) # for the above function
call_later.kwargs = {'_kwarg1': 11, '_kwarg2': 22} # for the above function
call_later.time_to_run = timezone.now() + timedelta(minutes=8)
call_later.save()

You can also repeatedly call your task:

call_later_twice.every = timedelta(seconds=1)
call_later_twice.repeat = 2

There are 2 types of failure:

  • If a task fails to run, it is run on the next checking event. By default, there are 3 attempts to run a function.
  • If a task takes too long to run, it is again run on the next checking event. By default, there are 3 retries.

...the task is labelled as problematic after repeated fails.

Project details


Download files

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

Source Distribution

zappa_scheduler-1.0.7.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

zappa_scheduler-1.0.7-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file zappa_scheduler-1.0.7.tar.gz.

File metadata

  • Download URL: zappa_scheduler-1.0.7.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for zappa_scheduler-1.0.7.tar.gz
Algorithm Hash digest
SHA256 16b996b02ee16e57704f0492c18aff96f7d24e58b7f864b8d1256eb1e4859a96
MD5 e1b4dc2593576a9bcff1c9020130d53a
BLAKE2b-256 363cb0be8fa80ad3da2ac6fd35d59be0ee44074d31c08e40f4b25f001d9f7793

See more details on using hashes here.

File details

Details for the file zappa_scheduler-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: zappa_scheduler-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for zappa_scheduler-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e4f9a8ee61f5f78dc73fd3027bfc639fb8e4e6eb6d867e648f6e1b14a722b6
MD5 231c013d9054d9c9058e2fbe9f957e02
BLAKE2b-256 ae9d3fa3825d789c5305fdf98fca80e662cb82557545b061c465d2e306d4e374

See more details on using hashes here.

Supported by

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