[Python-checkins] python/dist/src/Lib Queue.py,1.21,1.22
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Mon Jul 12 03:20:39 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6276/Lib
Modified Files:
Queue.py
Log Message:
Simplified the new get/get_nowait/put/put_nowait implementations a bit.
Index: Queue.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/Queue.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** Queue.py 12 Jul 2004 00:45:14 -0000 1.21
--- Queue.py 12 Jul 2004 01:20:32 -0000 1.22
***************
*** 69,77 ****
is ignored in that case).
"""
- if not block:
- return self.put_nowait(item)
self.not_full.acquire()
try:
! if timeout is None:
while self._full():
self.not_full.wait()
--- 69,78 ----
is ignored in that case).
"""
self.not_full.acquire()
try:
! if not block:
! if self._full():
! raise Full
! elif timeout is None:
while self._full():
self.not_full.wait()
***************
*** 82,86 ****
while self._full():
remaining = endtime - _time()
! if remaining < 0.0:
raise Full
self.not_full.wait(remaining)
--- 83,87 ----
while self._full():
remaining = endtime - _time()
! if remaining <= 0.0:
raise Full
self.not_full.wait(remaining)
***************
*** 96,108 ****
Otherwise raise the Full exception.
"""
! self.not_full.acquire()
! try:
! if self._full():
! raise Full
! else:
! self._put(item)
! self.not_empty.notify()
! finally:
! self.not_full.release()
def get(self, block=True, timeout=None):
--- 97,101 ----
Otherwise raise the Full exception.
"""
! return self.put(item, False)
def get(self, block=True, timeout=None):
***************
*** 117,125 ****
in that case).
"""
- if not block:
- return self.get_nowait()
self.not_empty.acquire()
try:
! if timeout is None:
while self._empty():
self.not_empty.wait()
--- 110,119 ----
in that case).
"""
self.not_empty.acquire()
try:
! if not block:
! if self._empty():
! raise Empty
! elif timeout is None:
while self._empty():
self.not_empty.wait()
***************
*** 130,134 ****
while self._empty():
remaining = endtime - _time()
! if remaining < 0.0:
raise Empty
self.not_empty.wait(remaining)
--- 124,128 ----
while self._empty():
remaining = endtime - _time()
! if remaining <= 0.0:
raise Empty
self.not_empty.wait(remaining)
***************
*** 145,158 ****
raise the Empty exception.
"""
! self.not_empty.acquire()
! try:
! if self._empty():
! raise Empty
! else:
! item = self._get()
! self.not_full.notify()
! return item
! finally:
! self.not_empty.release()
# Override these methods to implement other queue organizations
--- 139,143 ----
raise the Empty exception.
"""
! return self.get(False)
# Override these methods to implement other queue organizations
More information about the Python-checkins
mailing list