From 175b6d01148a59a573cfe2a446db315ee15140ae Mon Sep 17 00:00:00 2001 From: Phus Lu Date: Thu, 11 Sep 2014 23:06:57 +0800 Subject: [PATCH] begin work for youtube stop --- local/proxy.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/local/proxy.py b/local/proxy.py index 6e8b331da..e386ce9a8 100644 --- a/local/proxy.py +++ b/local/proxy.py @@ -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)) @@ -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: