Skip to main content

An easy job scheduling interface for flask projects.

Project description

An easy job scheduling interface for flask projects.

Install

pip install flask_jobs

Schedule a job to run ASAP

from flask_jobs import AddJob

def Callback(*args, **kwargs):
    print('The Callback function was called with args=', args, ' and kwargs=', kwargs)

newJob = AddJob(
    func=Callback,
    a=(1, 'two', {'three': '4'}),
    k={'key': 'word'},
)

# The job will be run in a separate thread ASAP.

# You can check the status of your job
print('newJob['status']=', newJob['status']) # will return 'pending' or 'complete' or 'error'
>> newJob['status']= complete

Schedule a job to happen once in the future

from flask_jobs import ScheduleJob
import datetime

def Callback(*args, **kwargs):
    print('The Callback function was called with args=', args, ' and kwargs=', kwargs)

newJob = ScheduleJob(
    dt=datetime.datetime.utcnow() + datetime.timedelta(seconds=10), # all datetimes are in UTC
    func=Callback,
    a=(1, 'two', {'three': '4'}),
    k={'key': 'word'},
)

# The job will be run in a separate thread ASAP.

# You can check the status of your job
print('newJob['status']=', newJob['status']) # will return 'pending' or 'complete' or 'error'
>> newJob['status']= pending
# wait 10 seconds
print('newJob['status']=', newJob['status'])
>> newJob['status']= complete

Schedule a job to repeat indefinitely

from flask_jobs import RepeatJob

def Callback(*args, **kwargs):
    print('The Callback function was called with args=', args, ' and kwargs=', kwargs)

RepeatJob(
    dt=datetime.datetime.utcnow(),
    seconds=30,
    func=JobCallback,
    args=('Repeating',),
    kwargs={'key': 'val'}
)

# All jobs are persistent. Even if you restart your server.

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

flask_jobs-0.0.12.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

flask_jobs-0.0.12-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file flask_jobs-0.0.12.tar.gz.

File metadata

  • Download URL: flask_jobs-0.0.12.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for flask_jobs-0.0.12.tar.gz
Algorithm Hash digest
SHA256 530b35d625274b76058c14f1335ae74e169c51d97e3f4015962642801b60859c
MD5 6cbde62ae158afe363e6535cc109a23a
BLAKE2b-256 8dda48fd57b170588153abdff51e07dbe2796a16eafed76577fce72e8620b22d

See more details on using hashes here.

File details

Details for the file flask_jobs-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: flask_jobs-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.2

File hashes

Hashes for flask_jobs-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 00e952482c2e6bc256c587ca2c8cc3f0d5ce99a1470ae227949401135bf764f3
MD5 6a195d6ee5f9972a62969d2028797aff
BLAKE2b-256 f0ceddec82d95839e72e73ead3fe8663273dc679e05af082808c5faa343af980

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