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
Release history Release notifications | RSS feed
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.7.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for flask_jobs-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 696c5dfcf08b3f4e85cda290d0bc9b2d33da5a74f1d911b716b3f92b20ce23ed |
|
MD5 | 3af39a5b824d5ab941e197154f10dbce |
|
BLAKE2b-256 | 93afb647cf10786d1a00a2fe32ca5750a554ec70761b497790ba6fd54a6e7d23 |