Skip to content

Commit

Permalink
begin work for youtube stop
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Sep 11, 2014
1 parent 625d50a commit 175b6d0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions local/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,11 @@ def __fetchlet(self, range_queue, data_queue, range_delay_size):
if self._stopped:
response.close()
return
data = response.read(self.bufsize)
data = None
with gevent.Timeout(1, False):
data = response.read(self.bufsize)
if data is None:
logging.warning('response.read(%r) timeout', self.bufsize)
if not data:
break
data_queue.put((start, data))
Expand Down Expand Up @@ -453,7 +457,11 @@ def handle(self, handler, **kwargs):
handler.end_headers()
bufsize = 8192
while True:
data = response.read(bufsize)
data = None
with gevent.Timeout(2, False):
data = response.read(bufsize)
if data is None:
logging.warning('response.read(%r) timeout', bufsize)
if data:
handler.wfile.write(data)
if not data:
Expand Down

0 comments on commit 175b6d0

Please sign in to comment.