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
87b779b7
Commit
87b779b7
authored
Mar 21, 2009
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
port the queue change r70405
parent
c0279506
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
Lib/queue.py
Lib/queue.py
+8
-8
No files found.
Lib/queue.py
View file @
87b779b7
"""A multi-producer, multi-consumer queue."""
from
time
import
time
as
_time
try
:
import
threading
as
_threading
except
ImportError
:
import
dummy_threading
as
_threading
from
collections
import
deque
import
heapq
...
...
@@ -20,26 +24,22 @@ class Queue:
If maxsize is <= 0, the queue size is infinite.
"""
def
__init__
(
self
,
maxsize
=
0
):
try
:
import
threading
except
ImportError
:
import
dummy_threading
as
threading
self
.
maxsize
=
maxsize
self
.
_init
(
maxsize
)
# mutex must be held whenever the queue is mutating. All methods
# that acquire mutex must release it before returning. mutex
# is shared between the three conditions, so acquiring and
# releasing the conditions also acquires and releases mutex.
self
.
mutex
=
threading
.
Lock
()
self
.
mutex
=
_
threading
.
Lock
()
# Notify not_empty whenever an item is added to the queue; a
# thread waiting to get is notified then.
self
.
not_empty
=
threading
.
Condition
(
self
.
mutex
)
self
.
not_empty
=
_
threading
.
Condition
(
self
.
mutex
)
# Notify not_full whenever an item is removed from the queue;
# a thread waiting to put is notified then.
self
.
not_full
=
threading
.
Condition
(
self
.
mutex
)
self
.
not_full
=
_
threading
.
Condition
(
self
.
mutex
)
# Notify all_tasks_done whenever the number of unfinished tasks
# drops to zero; thread waiting to join() is notified to resume
self
.
all_tasks_done
=
threading
.
Condition
(
self
.
mutex
)
self
.
all_tasks_done
=
_
threading
.
Condition
(
self
.
mutex
)
self
.
unfinished_tasks
=
0
def
task_done
(
self
):
...
...
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