dbader / dbader/schedule

Jobs dependency - How to create schedule with jobs dependency?

Open
#215 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
12.3k
Forks
999
PR merge metrics
No merged PRs in 30d

Description

How to create schedule with jobs dependency?
Example:
job2 execute only if job1 executed with success.

I try do this, but not working:

```
import schedule
import time

def now():
return time.strftime("%H:%M:%S")

def job1():
print("Working 10..." + now())
time.sleep(10)
print("Working 11..." + now())

def job2():
print("Working 20..." + now())
time.sleep(10)
print("Working 21..." + now())

schedule.every(30).seconds.do(job1).do(job2)

```

The program execute only last "do".
Result of execution:
I'm working 20...17:39:34
I'm working 21...17:39:44
I'm working 20...17:39:44
I'm working 21...17:39:54
I'm working 20...17:39:54
I'm working 21...17:40:04

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the chained schedule.every(30).seconds.do(job1).do(job2) example and inspect how the chained calls are registered and executed. Compare the observed output with the requested success-dependent ordering; done should be an agreed behavior for running job2 only after job1 succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.