Using Django Async from your code
Created 2014-09-23T05:00:00.203Z, last edited 2014-09-23T11:49:09.156Z
async.schedule
schedule(function, args = None, kwargs = None, run_after= None, meta = None, priority = 5, group = None)
Returns a Job instance that is used to record the task in the database. The job has a method execute which will attempt to run the job. Don't do this directly until you've fully understood how transactions are handled
- function Either the fully qualified name of the function that is to be run, or the function itself.
- args A tuple or list of arguments to be given to the function.
- kwargs A dict containing key word arguments to be passed to the function.
- run_after The earliest time that the function should be run.
- meta Parameters for controlling how the function is to be executed.
- priority Jobs with higher numbers are always executed before jobs with lower numbers.
- group Jobs can be placed together into a group and the progress across all of them can be tracked. Pass either a group name or a group instance. See Groups for more details.
async.api.deschedule
deschedule(function, args = None, kwargs = None)
Marks all jobs in the queue that match the given function and arguments as executed.
De-scheduling does not guarantee that the de-scheduled tasks will never run. This is because the task might have already started executing within the queue whilst it is de-scheduled from outside the queue.
Due to instabilities in the way that Python's JSON serialisation works it's not guaranteed that you will be able to deschedule jobs by matching the kwargs. If you are going to want to deschedule jobs then you should always use args for parameters.
async.api.health
info = health()
Returns a dict containing basic information about the queue which can be used for monitoring.
async.api.remove_old_jobs
remove_old_jobs(remove_jobs_before_days=30, resched_hours=8)
Can be called to remove old executed and cancelled jobs from the queue as a form of garbage collection. Defaults to jobs that have been executed or cancelled more than 30 days previously, and it will default to rescheduling itself to run again eight hours later.
© 2002-2026 Kirit & Tai Sælensminde. All forum posts are copyright their respective authors.
Licensed under a Creative Commons License. Non-commercial use is fine so long as you provide attribution.

