Merge "Remove only_free param to Pool.get()"
This commit is contained in:
commit
377fa049fd
@ -45,21 +45,17 @@ class Pool(object):
|
|||||||
self._items.appendleft(item)
|
self._items.appendleft(item)
|
||||||
self._cond.notify()
|
self._cond.notify()
|
||||||
|
|
||||||
def get(self, only_free=False):
|
def get(self):
|
||||||
"""Return an item from the pool, when one is available.
|
"""Return an item from the pool, when one is available.
|
||||||
|
|
||||||
This may cause the calling thread to block.
|
This may cause the calling thread to block.
|
||||||
|
|
||||||
:param only_free: if True, return None if no free item available
|
|
||||||
:type only_free: bool
|
|
||||||
"""
|
"""
|
||||||
with self._cond:
|
with self._cond:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
return self._items.popleft()
|
return self._items.popleft()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
if only_free:
|
pass
|
||||||
return None
|
|
||||||
|
|
||||||
if self._current_size < self._max_size:
|
if self._current_size < self._max_size:
|
||||||
self._current_size += 1
|
self._current_size += 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user