Обработка таймаута при закрытии потока.
[vpproxy.git] / vlcclient / vlcclient.py
index 80fc0f7850974d3aea32ffd03107a368d29a8b26..949215627f5c9fc89fc87c6fb8104950669533c2 100644 (file)
@@ -9,7 +9,6 @@ import telnetlib
 import logging
 from vlcmessages import *
 import time
-from pprint import pprint
 
 class VlcException(Exception):
 
@@ -181,13 +180,22 @@ class VlcClient(object):
       self._resultlock.acquire()
       to_stop=set()
       for stream,lasttime in self.streams.iteritems():
-        print stream,lasttime
         if time.time()-lasttime>timeout:
           to_stop.add(stream)
       for stream in to_stop:    
-        self.stopBroadcast(stream)
+        try:
+          self.stopBroadcast(stream)
+        except:
+          pass  
       self._resultlock.release()
 
+    def check_stream(self,stream_name):
+      if stream_name in self.streams:
+        self.streams[stream_name]=time.time()
+        return True
+      else:
+        return False  
+
     def pauseBroadcast(self, stream_name):
         return self._write(VlcMessage.request.pauseBroadcast(stream_name))