Revision 1673
Added by Aaron Marcuse-Kubitza almost 13 years ago
streams.py | ||
---|---|---|
1 | 1 |
# I/O |
2 | 2 |
|
3 |
import timeout |
|
3 |
import timeouts
|
|
4 | 4 |
|
5 | 5 |
class WrapStream: |
6 | 6 |
'''Forwards close() to the underlying stream''' |
... | ... | |
30 | 30 |
return line |
31 | 31 |
|
32 | 32 |
class TimeoutInputStream(WrapStream): |
33 |
'''@param timeout_ sec'''
|
|
34 |
def __init__(self, stream, timeout_):
|
|
33 |
'''@param timeout sec''' |
|
34 |
def __init__(self, stream, timeout): |
|
35 | 35 |
WrapStream.__init__(self, stream) |
36 |
self.timeout = timeout_
|
|
36 |
self.timeout = timeout |
|
37 | 37 |
|
38 | 38 |
def readline(self): |
39 |
return timeout.run(lambda: self.stream.readline(), self.timeout) |
|
39 |
return timeouts.run(lambda: self.stream.readline(), self.timeout)
|
|
40 | 40 |
|
41 | 41 |
class TracedOutputStream: |
42 | 42 |
'''Wraps an output stream, running a trace function on each string written |
Also available in: Unified diff
Renamed timeout.py to timeouts.py. Renamed timeout_ vars to timeout.