Merge "Remove only_free param to Pool.get()"

This commit is contained in:
Jenkins 2013-07-31 05:59:47 +00:00 committed by Gerrit Code Review
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