diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-03-15 12:05:41 (GMT) |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2012-03-15 12:05:41 (GMT) |
commit | a4e018889ac3537e10b48811b4be6356e633b8a0 (patch) | |
tree | ef43ce4ff4f5bd657b7dd17e234bb1a388c7e69b /Lib/sched.py | |
parent | 17160fd6d6d7850294a9a465a3e5e399e5028bb6 (diff) | |
download | cpython-a4e018889ac3537e10b48811b4be6356e633b8a0.zip cpython-a4e018889ac3537e10b48811b4be6356e633b8a0.tar.gz cpython-a4e018889ac3537e10b48811b4be6356e633b8a0.tar.bz2 |
(sched) when run() is invoked with blocking=False return the deadline of the next scheduled call in the scheduler; this use case was suggested in http://bugs.python.org/issue1641#msg149453
Diffstat (limited to 'Lib/sched.py')
-rw-r--r-- | Lib/sched.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/sched.py b/Lib/sched.py index bd1f427..a89a118 100644 --- a/Lib/sched.py +++ b/Lib/sched.py @@ -97,7 +97,8 @@ class scheduler: def run(self, blocking=True): """Execute events until the queue is empty. If blocking is False executes the scheduled events due to - expire soonest (if any) and then return. + expire soonest (if any) and then return the deadline of the + next scheduled call in the scheduler. When there is a positive delay until the first event, the delay function is called and the event is left in the queue; @@ -129,7 +130,7 @@ class scheduler: now = timefunc() if now < time: if not blocking: - return + return time - now delayfunc(time - now) else: event = pop(q) |