[issue24411] Drop redundant lock in queue.Queue methods qsize(), empty() and full()

Raymond Hettinger report at bugs.python.org
Tue Jun 9 07:38:30 CEST 2015


Raymond Hettinger added the comment:

It may seem pointless to hold the lock, but it is guaranteed behavior (and has been so for a very, very long time).

'''
    # Override these methods to implement other queue organizations                                                               
    # (e.g. stack or priority queue).                                                                                             
    # These will only be called with appropriate locks held   

    # Initialize the queue representation                                                                                         
    def _init(self, maxsize):
        self.queue = deque()

    def _qsize(self):
        return len(self.queue)

    # Put a new item in the queue                                                                                                 
    def _put(self, item):
        self.queue.append(item)

    # Get an item from the queue                                                                                                  
    def _get(self):
        return self.queue.popleft()
 
'''

----------
versions:  -Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24411>
_______________________________________


More information about the Python-bugs-list mailing list