-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streaming: disconnect on keep_alive() #897
Comments
I support this. I'd too rather have the keep_alive() function return a boolean to determine whether or not the connection continues to exist. Currently, my workaround is to raise an exception in the keep_alive function, and override the on_exception function to return false. |
I would also like to see this implemented. |
Allow to close stream on keep-alive messages. This fix allows to disconnect the stream at the next keep-alive message received. This is possible by either calling disconnect() or having keep_alive() returning False.
This should be resolved with 37e701e by allowing I opted not to use the approach of allowing a I also intend to merge Afterwards, I anticipate being able to simplify the handling of each line of data, so as to allow the stream to disconnect immediately if |
This is now done, with 7fc85f6, 7756fa8, and e348c36.
This is now done with 39abff4.
This was also done with 7756fa8. |
Hi
I have a use case where I want to connect to the streaming API for a period of time and then disconnect even when no tweet is received during that period.
When no tweet is received, I can check if defined duration has elapsed in StreamListener keep_alive(), but there is no mechanism to disconnect in this case since _read_loop() is not reading any return value from keep_alive() and there is no way to break the loop in this situation.
As a workaround I am rising a custom exception in my implementation of keep_alive() but this is not ideal, I understand that a better solution is to let keep_alive() return a boolean that when is false breaks the read loop, same as on_data(), on_status(), etc.
The text was updated successfully, but these errors were encountered: