Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7200efd2
Commit
7200efd2
authored
Nov 22, 2011
by
Giampaolo Rodola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sort last committed name in alphabetical order
parent
c2e22649
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
Lib/sched.py
Lib/sched.py
+8
-0
Misc/ACKS
Misc/ACKS
+1
-1
No files found.
Lib/sched.py
View file @
7200efd2
...
...
@@ -35,6 +35,9 @@ from collections import namedtuple
__all__
=
[
"scheduler"
]
class
Event
(
namedtuple
(
'Event'
,
'time, priority, action, argument, kwargs'
)):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Event
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
_scheduled
=
False
def
__eq__
(
s
,
o
):
return
(
s
.
time
,
s
.
priority
)
==
(
o
.
time
,
o
.
priority
)
def
__ne__
(
s
,
o
):
return
(
s
.
time
,
s
.
priority
)
!=
(
o
.
time
,
o
.
priority
)
def
__lt__
(
s
,
o
):
return
(
s
.
time
,
s
.
priority
)
<
(
o
.
time
,
o
.
priority
)
...
...
@@ -59,6 +62,7 @@ class scheduler:
"""
event
=
Event
(
time
,
priority
,
action
,
argument
,
kwargs
)
event
.
_scheduled
=
True
heapq
.
heappush
(
self
.
_queue
,
event
)
return
event
# The ID
...
...
@@ -81,6 +85,9 @@ class scheduler:
self
.
_queue
.
remove
(
event
)
heapq
.
heapify
(
self
.
_queue
)
def
is_scheduled
(
self
,
event
):
return
event
.
_scheduled
def
empty
(
self
):
"""Check whether the queue is empty."""
return
not
self
.
_queue
...
...
@@ -122,6 +129,7 @@ class scheduler:
# Verify that the event was not removed or altered
# by another thread after we last looked at q[0].
if
event
is
checked_event
:
event
.
_scheduled
=
False
action
(
*
argument
,
**
kwargs
)
delayfunc
(
0
)
# Let other threads run
else
:
...
...
Misc/ACKS
View file @
7200efd2
...
...
@@ -11,7 +11,6 @@ Without you, I would've stopped working on Python long ago!
PS: In the standard Python distribution, this file is encoded in UTF-8
and the list is in rough alphabetical order by last names.
Chris Clark
Rajiv Abraham
David Abrahams
Ron Adam
...
...
@@ -179,6 +178,7 @@ Tom Christiansen
Vadim Chugunov
David Cinege
Craig Citro
Chris Clark
Mike Clarkson
Andrew Clegg
Brad Clements
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment