summaryrefslogtreecommitdiff
path: root/Lib/sched.py
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2012-03-15 13:05:41 +0100
committerGiampaolo Rodola' <g.rodola@gmail.com>2012-03-15 13:05:41 +0100
commitfb14c6d816b8da34655376c2772974764ac12cc3 (patch)
tree17e38f7217f215c04070ee06039d33e9a2205e3a /Lib/sched.py
parent82b0210a72a26d596a02368c3044b16e846727a1 (diff)
downloadcpython-fb14c6d816b8da34655376c2772974764ac12cc3.tar.gz
(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.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/sched.py b/Lib/sched.py
index bd1f42734a..a89a118788 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)