mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
(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
This commit is contained in:
parent
17160fd6d6
commit
a4e018889a
2 changed files with 5 additions and 3 deletions
|
@ -109,7 +109,8 @@ Scheduler Objects
|
||||||
on until there are no more scheduled events.
|
on until there are no more scheduled events.
|
||||||
|
|
||||||
If *blocking* is False executes the scheduled events due to expire soonest
|
If *blocking* is False executes the scheduled events due to expire soonest
|
||||||
(if any) and then return.
|
(if any) and then return the deadline of the next scheduled call in the
|
||||||
|
scheduler (if any).
|
||||||
|
|
||||||
Either *action* or *delayfunc* can raise an exception. In either case, the
|
Either *action* or *delayfunc* can raise an exception. In either case, the
|
||||||
scheduler will maintain a consistent state and propagate the exception. If an
|
scheduler will maintain a consistent state and propagate the exception. If an
|
||||||
|
|
|
@ -97,7 +97,8 @@ class scheduler:
|
||||||
def run(self, blocking=True):
|
def run(self, blocking=True):
|
||||||
"""Execute events until the queue is empty.
|
"""Execute events until the queue is empty.
|
||||||
If blocking is False executes the scheduled events due to
|
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
|
When there is a positive delay until the first event, the
|
||||||
delay function is called and the event is left in the queue;
|
delay function is called and the event is left in the queue;
|
||||||
|
@ -129,7 +130,7 @@ class scheduler:
|
||||||
now = timefunc()
|
now = timefunc()
|
||||||
if now < time:
|
if now < time:
|
||||||
if not blocking:
|
if not blocking:
|
||||||
return
|
return time - now
|
||||||
delayfunc(time - now)
|
delayfunc(time - now)
|
||||||
else:
|
else:
|
||||||
event = pop(q)
|
event = pop(q)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue