Provide a hook for subclasses to do something when a response closes.
authorDan Fairs <dan@fezconsulting.com>
Sat, 4 Feb 2012 16:22:56 +0000 (16:22 +0000)
committerDan Fairs <dan@fezconsulting.com>
Sat, 4 Feb 2012 16:22:56 +0000 (16:22 +0000)
tweepy/streaming.py

index 6f8b4a69f86152142a71495442425b52d92aaf9c..dd144aaf35dc7adc7e0deba30487a89808f88cb4 100644 (file)
@@ -157,6 +157,8 @@ class Stream(object):
                 # buffer
                 buf += c
 
+        if resp.isclosed():
+            self.on_closed(resp)
 
     def _start(self, async):
         self.running = True
@@ -165,6 +167,10 @@ class Stream(object):
         else:
             self._run()
 
+    def on_closed(self, resp):
+        """ Called when the response has been closed by Twitter """
+        pass
+
     def userstream(self, count=None, async=False, secure=True):
         if self.running:
             raise TweepError('Stream object already connected!')