BufferedPipe
This commit is contained in:
parent
91c47b1748
commit
a529e93256
|
@ -17,7 +17,7 @@
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Attempt to generalize the "feeder" part of a Channel: an object which can be
|
Attempt to generalize the "feeder" part of a `.Channel`: an object which can be
|
||||||
read from and closed, but is reading from a buffer fed by another thread. The
|
read from and closed, but is reading from a buffer fed by another thread. The
|
||||||
read operations are blocking and can have a timeout set.
|
read operations are blocking and can have a timeout set.
|
||||||
"""
|
"""
|
||||||
|
@ -107,19 +107,18 @@ class BufferedPipe (object):
|
||||||
|
|
||||||
The optional ``timeout`` argument can be a nonnegative float expressing
|
The optional ``timeout`` argument can be a nonnegative float expressing
|
||||||
seconds, or ``None`` for no timeout. If a float is given, a
|
seconds, or ``None`` for no timeout. If a float is given, a
|
||||||
``PipeTimeout`` will be raised if the timeout period value has
|
`.PipeTimeout` will be raised if the timeout period value has elapsed
|
||||||
elapsed before any data arrives.
|
before any data arrives.
|
||||||
|
|
||||||
:param nbytes: maximum number of bytes to read
|
:param int nbytes: maximum number of bytes to read
|
||||||
:type nbytes: int
|
:param float timeout:
|
||||||
:param timeout: maximum seconds to wait (or ``None``, the default, to
|
maximum seconds to wait (or ``None``, the default, to wait forever)
|
||||||
wait forever)
|
|
||||||
:type timeout: float
|
|
||||||
:return: data
|
:return: data
|
||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
:raises PipeTimeout: if a timeout was specified and no data was ready
|
:raises PipeTimeout:
|
||||||
before that timeout
|
if a timeout was specified and no data was ready before that
|
||||||
|
timeout
|
||||||
"""
|
"""
|
||||||
out = ''
|
out = ''
|
||||||
self._lock.acquire()
|
self._lock.acquire()
|
||||||
|
@ -189,7 +188,7 @@ class BufferedPipe (object):
|
||||||
"""
|
"""
|
||||||
Return the number of bytes buffered.
|
Return the number of bytes buffered.
|
||||||
|
|
||||||
:return: number of bytes bufferes
|
:return: number of bytes buffered
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
self._lock.acquire()
|
self._lock.acquire()
|
||||||
|
|
Loading…
Reference in New Issue