Closed mlexs closed 1 year ago
What I do to run a job is call the job.run() method. I use the get_jobs() method to find the job I need to run and I have each job have a uuid as a tag so I can find it with get_jobs(). It is dependent on whether you have a job created, but it works just fine. My design is to have a task that contains multiple jobs. Each task has a uuid and each job has a uuid. I can then get and run any task or job and call the schedule.py to run any of them.
If you want a job that runs just once, there are references in the issues list that goes over doing that. It basically entails your job method having something to cause the schedule_next to not be set. All I have is a thread that calls schedule.run_pending() every 30 seconds for those jobs that are scheduled and a queue for direct actions.
Great library. Thanks!
Our app has a single scheduler with 2 jobs. One job runs once a day to compute some heavy lifting, and other job is simply performing a request to S3 bucket (this might be quick task or slightly longer like 30secs).
The 2nd job needs to happen as soon as the user finishes their specific action, so is it possible to manually invoke a job with this library?
I could not see anything in the documentation. It's a little weird requirement to expect me that a "periodical functions" can get invoked from my code on request.
I know there's
run_all
but this will run all jobs. I'm only interested in the single one (we might have more other job types in the future..).I have used little work-around by tagging the job, then finding it and invoking as needed. Sample code:
jobs.py
then in
x.py
But I would appreciate if someone has better idea for such requirement?.