Why does not the time difference between the two schedules meet expectations?
- Dominant language
- Python
- Stars
- 12.3k
- Forks
- 999
- PR merge metrics
- No merged PRs in 30d
Description
when I run the following code, I find the result is confusing me. Can anyone help me?
```python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import time
import datetime
import schedule
def work():
print 'start: ', datetime.datetime.now()
time.sleep(15)
print 'end : ', datetime.datetime.now()
def main():
schedule.every(1).minute.do(work)
while True:
schedule.run_pending()
time.sleep(0.01)
main()
```
The result is as follows:
```
start: 2017-11-09 14:16:32.320981
end : 2017-11-09 14:16:47.336356
start: 2017-11-09 14:17:47.340923
end : 2017-11-09 14:18:02.355287
start: 2017-11-09 14:19:02.361218
end : 2017-11-09 14:19:17.375502
start: 2017-11-09 14:20:17.377436
end : 2017-11-09 14:20:32.392757
start: 2017-11-09 14:21:32.401274
end : 2017-11-09 14:21:47.415794
```
Why the time difference between two 'start' is not 1 min, but 75s?
Program execution time should be regarded inner time between the scheduling period.
in my viewpoint, the correct time difference is 1 min. the delay caused by time.sleep(15) should not affect.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the supplied Python example and tracing schedule.every(...), schedule.run_pending(), and work(); compare the observed start times with the scheduler's documented behavior. Done means the expected timing semantics are confirmed and, if the behavior is considered wrong, covered by a focused test or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100