select: add missing get(block=..) parameter.
This commit is contained in:
parent
ddf28987a0
commit
4bf3d01104
|
@ -151,7 +151,7 @@ contexts.
|
||||||
Result processing happens concurrently to new results arriving, so
|
Result processing happens concurrently to new results arriving, so
|
||||||
:py:meth:`all` should always be faster.
|
:py:meth:`all` should always be faster.
|
||||||
|
|
||||||
.. py:method:: get (timeout=None)
|
.. py:method:: get (timeout=None, block=True)
|
||||||
|
|
||||||
Fetch the next available value from any receiver, or raise
|
Fetch the next available value from any receiver, or raise
|
||||||
:py:class:`mitogen.core.TimeoutError` if no value is available within
|
:py:class:`mitogen.core.TimeoutError` if no value is available within
|
||||||
|
@ -162,7 +162,9 @@ contexts.
|
||||||
|
|
||||||
:param float timeout:
|
:param float timeout:
|
||||||
Timeout in seconds.
|
Timeout in seconds.
|
||||||
|
:param bool block:
|
||||||
|
If :py:data:`False`, immediately raise
|
||||||
|
:py:class:`mitogen.core.TimeoutError` if the select is empty.
|
||||||
:return:
|
:return:
|
||||||
:py:class:`mitogen.core.Message`
|
:py:class:`mitogen.core.Message`
|
||||||
:raises mitogen.core.TimeoutError:
|
:raises mitogen.core.TimeoutError:
|
||||||
|
|
|
@ -113,12 +113,12 @@ class Select(object):
|
||||||
|
|
||||||
empty_msg = 'Cannot get(), Select instance is empty'
|
empty_msg = 'Cannot get(), Select instance is empty'
|
||||||
|
|
||||||
def get(self, timeout=None):
|
def get(self, timeout=None, block=True):
|
||||||
if not self._receivers:
|
if not self._receivers:
|
||||||
raise Error(self.empty_msg)
|
raise Error(self.empty_msg)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
recv = self._latch.get(timeout=timeout)
|
recv = self._latch.get(timeout=timeout, block=block)
|
||||||
try:
|
try:
|
||||||
msg = recv.get(block=False)
|
msg = recv.get(block=False)
|
||||||
if self._oneshot:
|
if self._oneshot:
|
||||||
|
|
Loading…
Reference in New Issue