Skip to content

Commit ddca7c7

Browse files
author
georg.brandl
committed
Queue renaming reversal part 3: move module into place and
change imports and other references. Closes #2925. git-svn-id: http://svn.python.org/projects/python/trunk@63603 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 2d298f3 commit ddca7c7

File tree

15 files changed

+55
-59
lines changed

15 files changed

+55
-59
lines changed

Doc/library/queue.rst

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
===========================================
33

44
.. module:: Queue
5-
:synopsis: Old name for the queue module.
6-
7-
.. module:: queue
85
:synopsis: A synchronized queue class.
96

107
.. note::
11-
The :mod:`Queue` module has been renamed to :mod:`queue` in Python 3.0. It
12-
is importable under both names in Python 2.6 and the rest of the 2.x series.
8+
The :mod:`Queue` module has been renamed to :mod:`queue` in Python 3.0. The
9+
:term:`2to3` tool will automatically adapt imports when converting your
10+
sources to 3.0.
1311

1412

15-
The :mod:`queue` module implements multi-producer, multi-consumer queues.
13+
The :mod:`Queue` module implements multi-producer, multi-consumer queues.
1614
It is especially useful in threaded programming when information must be
1715
exchanged safely between multiple threads. The :class:`Queue` class in this
1816
module implements all the required locking semantics. It depends on the
@@ -26,7 +24,7 @@ the first retrieved (operating like a stack). With a priority queue,
2624
the entries are kept sorted (using the :mod:`heapq` module) and the
2725
lowest valued entry is retrieved first.
2826

29-
The :mod:`queue` module defines the following classes and exceptions:
27+
The :mod:`Queue` module defines the following classes and exceptions:
3028

3129
.. class:: Queue(maxsize)
3230

@@ -75,7 +73,7 @@ Queue Objects
7573
-------------
7674

7775
Queue objects (:class:`Queue`, :class:`LifoQueue`, or :class:`PriorityQueue`)
78-
provide the public methods described below.
76+
provide the public methods described below.
7977

8078

8179
.. method:: Queue.qsize()
@@ -170,20 +168,20 @@ fully processed by daemon consumer threads.
170168

171169
Example of how to wait for enqueued tasks to be completed::
172170

173-
def worker():
174-
while True:
175-
item = q.get()
176-
do_work(item)
177-
q.task_done()
171+
def worker():
172+
while True:
173+
item = q.get()
174+
do_work(item)
175+
q.task_done()
178176

179-
q = Queue()
180-
for i in range(num_worker_threads):
177+
q = Queue()
178+
for i in range(num_worker_threads):
181179
t = Thread(target=worker)
182180
t.setDaemon(True)
183-
t.start()
181+
t.start()
184182

185183
for item in source():
186-
q.put(item)
184+
q.put(item)
187185

188186
q.join() # block until all tasks are done
189187

Doc/library/threading.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This module constructs higher-level threading interfaces on top of the lower
1010
level :mod:`thread` module.
11-
See also the :mod:`mutex` and :mod:`queue` modules.
11+
See also the :mod:`mutex` and :mod:`Queue` modules.
1212

1313
The :mod:`dummy_threading` module is provided for situations where
1414
:mod:`threading` cannot be used because :mod:`thread` is missing.

Doc/reference/simple_stmts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ The :keyword:`raise` statement
534534
If no expressions are present, :keyword:`raise` re-raises the last exception
535535
that was active in the current scope. If no exception is active in the current
536536
scope, a :exc:`TypeError` exception is raised indicating that this is an error
537-
(if running under IDLE, a :exc:`queue.Empty` exception is raised instead).
537+
(if running under IDLE, a :exc:`Queue.Empty` exception is raised instead).
538538

539539
Otherwise, :keyword:`raise` evaluates the expressions to get three objects,
540540
using ``None`` as the value of omitted expressions. The first two objects are

Doc/tutorial/stdlib2.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Output Formatting
1616
The :mod:`repr` module provides a version of :func:`repr` customized for
1717
abbreviated displays of large or deeply nested containers::
1818

19-
>>> import repr
19+
>>> import repr
2020
>>> repr.repr(set('supercalifragilisticexpialidocious'))
2121
"set(['a', 'c', 'd', 'e', 'f', 'g', ...])"
2222

@@ -174,7 +174,7 @@ tasks in background while the main program continues to run::
174174

175175
class AsyncZip(threading.Thread):
176176
def __init__(self, infile, outfile):
177-
threading.Thread.__init__(self)
177+
threading.Thread.__init__(self)
178178
self.infile = infile
179179
self.outfile = outfile
180180
def run(self):
@@ -198,9 +198,9 @@ variables, and semaphores.
198198
While those tools are powerful, minor design errors can result in problems that
199199
are difficult to reproduce. So, the preferred approach to task coordination is
200200
to concentrate all access to a resource in a single thread and then use the
201-
:mod:`queue` module to feed that thread with requests from other threads.
202-
Applications using :class:`Queue` objects for inter-thread communication and
203-
coordination are easier to design, more readable, and more reliable.
201+
:mod:`Queue` module to feed that thread with requests from other threads.
202+
Applications using :class:`Queue.Queue` objects for inter-thread communication
203+
and coordination are easier to design, more readable, and more reliable.
204204

205205

206206
.. _tut-logging:
@@ -358,11 +358,11 @@ For example, calculating a 5% tax on a 70 cent phone charge gives different
358358
results in decimal floating point and binary floating point. The difference
359359
becomes significant if the results are rounded to the nearest cent::
360360

361-
>>> from decimal import *
361+
>>> from decimal import *
362362
>>> Decimal('0.70') * Decimal('1.05')
363363
Decimal("0.7350")
364364
>>> .70 * 1.05
365-
0.73499999999999999
365+
0.73499999999999999
366366

367367
The :class:`Decimal` result keeps a trailing zero, automatically inferring four
368368
place significance from multiplicands with two place significance. Decimal
@@ -380,7 +380,7 @@ calculations and equality tests that are unsuitable for binary floating point::
380380
>>> sum([Decimal('0.1')]*10) == Decimal('1.0')
381381
True
382382
>>> sum([0.1]*10) == 1.0
383-
False
383+
False
384384

385385
The :mod:`decimal` module provides arithmetic with as much precision as needed::
386386

Doc/whatsnew/2.6.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ details.
19651965
used to hold character data.
19661966
(Contributed by Achim Gaedke; :issue:`1137`.)
19671967

1968-
* The :mod:`queue` module now provides queue classes that retrieve entries
1968+
* The :mod:`Queue` module now provides queue classes that retrieve entries
19691969
in different orders. The :class:`PriorityQueue` class stores
19701970
queued items in a heap and retrieves them in priority order,
19711971
and :class:`LifoQueue` retrieves the most recently added entries first,
File renamed without changes.

Lib/idlelib/rpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import struct
3636
import cPickle as pickle
3737
import threading
38-
import queue
38+
import Queue
3939
import traceback
4040
import copy_reg
4141
import types
@@ -117,8 +117,8 @@ def handle_error(self, request, client_address):
117117
#----------------- end class RPCServer --------------------
118118

119119
objecttable = {}
120-
request_queue = queue.Queue(0)
121-
response_queue = queue.Queue(0)
120+
request_queue = Queue.Queue(0)
121+
response_queue = Queue.Queue(0)
122122

123123

124124
class SocketIO(object):
@@ -413,7 +413,7 @@ def pollresponse(self, myseq, wait):
413413
# send queued response if there is one available
414414
try:
415415
qmsg = response_queue.get(0)
416-
except queue.Empty:
416+
except Queue.Empty:
417417
pass
418418
else:
419419
seq, response = qmsg

Lib/idlelib/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import traceback
66
import thread
77
import threading
8-
import queue
8+
import Queue
99

1010
import CallTips
1111
import AutoComplete
@@ -85,7 +85,7 @@ def main(del_exitfunc=False):
8585
continue
8686
try:
8787
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
88-
except queue.Empty:
88+
except Queue.Empty:
8989
continue
9090
method, args, kwargs = request
9191
ret = method(*args, **kwargs)

Lib/test/test___all__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_all(self):
4040
self.check_all("configparser")
4141
self.check_all("Cookie")
4242
self.check_all("MimeWriter")
43-
self.check_all("queue")
43+
self.check_all("Queue")
4444
self.check_all("SimpleHTTPServer")
4545
self.check_all("SocketServer")
4646
self.check_all("StringIO")

Lib/test/test_dummy_thread.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
import dummy_thread as _thread
99
import time
10-
import queue
10+
import Queue
1111
import random
1212
import unittest
1313
from test import test_support
@@ -124,7 +124,7 @@ def arg_tester(queue, arg1=False, arg2=False):
124124
"""Use to test _thread.start_new_thread() passes args properly."""
125125
queue.put((arg1, arg2))
126126

127-
testing_queue = queue.Queue(1)
127+
testing_queue = Queue.Queue(1)
128128
_thread.start_new_thread(arg_tester, (testing_queue, True, True))
129129
result = testing_queue.get()
130130
self.failUnless(result[0] and result[1],
@@ -148,7 +148,7 @@ def queue_mark(queue, delay):
148148
queue.put(_thread.get_ident())
149149

150150
thread_count = 5
151-
testing_queue = queue.Queue(thread_count)
151+
testing_queue = Queue.Queue(thread_count)
152152
if test_support.verbose:
153153
print
154154
print "*** Testing multiple thread creation "\

0 commit comments

Comments
 (0)