Browse files

Fix regressions in timeout and process checking.

  • Loading branch information...
1 parent 7f59ae7 commit 02fabcb18e7594ba734038df3d4b7c830aa67248 @chrippa committed Nov 27, 2012
Showing with 10 additions and 10 deletions.
  1. +5 −5 src/livestreamer/stream/__init__.py
  2. +4 −4 src/livestreamer/utils.py
  3. +1 −1 tests/test_plugin_stream.py
View
10 src/livestreamer/stream/__init__.py
@@ -60,7 +60,6 @@ def open(self):
cmd = self._check_cmd()
def out_callback(data, queue, process):
- self.process_alive = process.alive
self.fd.write(data)
if self.errorlog:
@@ -80,11 +79,11 @@ def out_callback(data, queue, process):
time.sleep(0.5)
if pbs_compat:
- self.process_alive = stream.process.returncode is None
+ process_alive = stream.process.returncode is None
else:
- self.process_alive = stream.process.alive
+ process_alive = stream.process.alive
- if not self.process_alive:
+ if not process_alive:
if self.errorlog:
raise StreamError(("Error while executing subprocess, error output logged to: {0}").format(tmpfile.name))
else:
@@ -93,13 +92,14 @@ def out_callback(data, queue, process):
if pbs_compat:
return stream.process.stdout
else:
+ self.process = stream.process
return self
def read(self, size=0):
if not self.fd:
return b""
- while self.fd.length == 0 and self.process_alive:
+ while self.fd.length == 0 and self.process.alive:
if self.fd.elapsed_since_write() > self.timeout:
raise IOError("Read timeout")
View
8 src/livestreamer/utils.py
@@ -119,10 +119,10 @@ def write(self, data):
self.last_write = time()
def elapsed_since_write(self):
- if self.last_write > 0:
- return time() - self.last_write
- else:
- return 0
+ if self.last_write == 0:
+ self.last_write = time()
+
+ return time() - self.last_write
@property
def length(self):
View
2 tests/test_plugin_stream.py
@@ -53,7 +53,7 @@ def test_plugin(self):
"rtmp://hostname.se/stream", dict(live=True, num=47))
self._test_rtmp("rtmp://hostname.se/stream live=1 qarg='a \'string' noq=test",
- "rtmp://hostname.se/stream", dict(live=True, qarg="a \'string", noq="test"))
+ "rtmp://hostname.se/stream", dict(live=True, qarg='a \'string', noq="test"))
self._test_hls("hls://http://hostname.se/playlist.m3u8",
"http://hostname.se/playlist.m3u8")

0 comments on commit 02fabcb

Please sign in to comment.