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.14.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for flask_jobs-0.0.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7f8e02351ed3bfe2b835ed221ad82f14d9d0a6fbf5574723e7fbc47f3ca261e |
|
MD5 | b88bf8c455cdabafdd471e9391f2a257 |
|
BLAKE2b-256 | 45857b16204acfa5b300e373d90908852cadb21287b10ce63fa2c4371aca729a |