Skip to content

Commit 5e06813

Browse files
committed
Implement StreamListener.on_connect callback.
1 parent 247b02f commit 5e06813

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tweepy/streaming.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ class StreamListener(object):
2222
def __init__(self, api=None):
2323
self.api = api or API()
2424

25+
def on_connect(self):
26+
"""Called once connected to streaming server.
27+
28+
This will be invoked once a successful response
29+
is received from the server. Allows the listener
30+
to perform some work prior to entering the read loop.
31+
"""
32+
pass
33+
2534
def on_data(self, data):
2635
"""Called when raw data is received from connection.
2736
@@ -114,6 +123,7 @@ def _run(self):
114123
sleep(self.retry_time)
115124
else:
116125
error_counter = 0
126+
self.listener.on_connect()
117127
self._read_loop(resp)
118128
except timeout:
119129
if self.listener.on_timeout() == False:

0 commit comments

Comments
 (0)