Weekly job fails with interval > 1
- Dominant language
- Python
- Stars
- 12.3k
- Forks
- 999
- PR merge metrics
- No merged PRs in 30d
Description
Some assumptions are made in the code, which breaks if the interval is > 1.
Attached some unit test to expose the error:
[scheduler_weeks_test.txt](https://github.com/dbader/schedule/files/14167653/scheduler_weeks_test.txt)
### To fix:
In `_schedule_next_run` replace the lines from starting with `if days_ahead <= 0:` with the following
```
if days_ahead < 0: # Target day already happened this week
days_ahead += 7
if self.last_run is None:
self.next_run += datetime.timedelta(days_ahead) - self.period
elif self.last_run + self.period < datetime.datetime.now():
self.next_run += datetime.timedelta(days_ahead) - datetime.timedelta(days=7)
```
And a bit further down, at the end of the function, remove the following completely
```
if self.start_day is not None and self.at_time is not None:
# Let's see if we will still make that time we specified today
if (self.next_run - datetime.datetime.now()).days >= 7:
self.next_run -= self.period
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.