summaryrefslogtreecommitdiff
path: root/Lib/sched.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-09-02 20:43:20 +0000
committerGuido van Rossum <guido@python.org>1992-09-02 20:43:20 +0000
commit82b410ba57697bc0d2d651d0593f4e26c9cc7289 (patch)
tree919ce6e774608fbf5a2e4745472e9fbc445139e9 /Lib/sched.py
parenta07867d5b26aad9903a7882867e282f692c8932a (diff)
downloadcpython-82b410ba57697bc0d2d651d0593f4e26c9cc7289.tar.gz
Added a _v21 def to FL.py and added two new input field types
Added runcall(func, *args) interfaces to profile.py, bdb.py, pdb.py, wdb.py Added new module bisect.py and used it in sched.py. Mostly cosmetic changes to profile.py (changed output format).
Diffstat (limited to 'Lib/sched.py')
-rw-r--r--Lib/sched.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/Lib/sched.py b/Lib/sched.py
index 4a4530953d..685b2bc077 100644
--- a/Lib/sched.py
+++ b/Lib/sched.py
@@ -28,6 +28,8 @@
# XXX instead of having to define a module or class just to hold
# XXX the global state of your particular time and delay functtions.
+import bisect
+
class scheduler:
#
# Initialize a new instance, passing the time and delay functions
@@ -43,16 +45,7 @@ class scheduler:
# to remove it, if necessary.
#
def enterabs(self, event):
- time, priority, action, argument = event
- q = self.queue
- # XXX Could use bisection or linear interpolation?
- for i in range(len(q)):
- qtime, qpri, qact, qarg = q[i]
- if time < qtime: break
- if time == qtime and priority < qpri: break
- else:
- i = len(q)
- q.insert(i, event)
+ bisect.insort(self.queue, event)
return event # The ID
#
# A variant that specifies the time as a relative time.