Index: Lib/queue.py =================================================================== --- Lib/queue.py (revision 70202) +++ Lib/queue.py (working copy) @@ -3,6 +3,7 @@ from time import time as _time from collections import deque import heapq +import warnings __all__ = ['Empty', 'Full', 'Queue', 'PriorityQueue', 'LifoQueue'] @@ -92,6 +93,11 @@ def empty(self): """Return True if the queue is empty, False otherwise (not reliable!).""" + + warnings.warn("Queue.empty() is deprecated, and scheduled to be removed\ + in 3.2. Instead, use qsize() or catch a queue.Empty exception. ", + DeprecationWarning) + self.mutex.acquire() n = not self._qsize() self.mutex.release() @@ -99,6 +105,11 @@ def full(self): """Return True if the queue is full, False otherwise (not reliable!).""" + + warnings.warn("Queue.full() is deprecated, and scheduled to be removed\ + in 3.2. Instead, use qsize() or catch a queue.Empty exception. ", + DeprecationWarning) + self.mutex.acquire() n = 0 < self.maxsize == self._qsize() self.mutex.release() Index: Lib/multiprocessing/queues.py =================================================================== --- Lib/multiprocessing/queues.py (revision 70202) +++ Lib/multiprocessing/queues.py (working copy) @@ -113,9 +113,19 @@ return self._maxsize - self._sem._semlock._get_value() def empty(self): + + warnings.warn("Queue.empty() is deprecated, and scheduled to be removed\ + in 3.2. Instead, use qsize() or catch a queue.Empty exception. ", + DeprecationWarning) + return not self._poll() def full(self): + + warnings.warn("Queue.full() is deprecated, and scheduled to be removed\ + in 3.2. Instead, use qsize() or catch a queue.Empty exception. ", + DeprecationWarning) + return self._sem._semlock._is_zero() def get_nowait(self): @@ -320,6 +330,11 @@ self._make_methods() def empty(self): + + warnings.warn("Queue.empty() is deprecated, and scheduled to be removed\ + in 3.2. Instead, use qsize() or catch a queue.Empty exception. ", + DeprecationWarning) + return not self._reader.poll() def __getstate__(self): Index: Lib/test/test_multiprocessing.py =================================================================== --- Lib/test/test_multiprocessing.py (revision 70202) +++ Lib/test/test_multiprocessing.py (working copy) @@ -310,16 +310,16 @@ # def queue_empty(q): - if hasattr(q, 'empty'): - return q.empty() - else: - return q.qsize() == 0 + ''' + Helper method for this test suite to indicate an empty queue + ''' + return q.qsize() == 0 def queue_full(q, maxsize): - if hasattr(q, 'full'): - return q.full() - else: - return q.qsize() == maxsize + ''' + Helper method for this test suite to indicate a full queue + ''' + return q.qsize() == maxsize class _TestQueue(BaseTestCase): Index: Misc/NEWS =================================================================== --- Misc/NEWS (revision 70202) +++ Misc/NEWS (working copy) @@ -13,6 +13,8 @@ ----------------- ======= +- #Issue 5420: A deprecation warning has been added to Queue.empty() and + Queue.full(), plus all multiprocessing queue classes - The io module has been reimplemented in C for speed. Index: Tools/webchecker/wsgui.py =================================================================== --- Tools/webchecker/wsgui.py (revision 70202) +++ Tools/webchecker/wsgui.py (working copy) @@ -124,7 +124,7 @@ self.status_label.config(text=text) def check_msgq(self): - while not self.msgq.empty(): + while self.msgq.qsize() != 0: msg = self.msgq.get() if msg is None: self.go_button.configure(state=NORMAL)