Closed ArnoldWolfstein closed 2 years ago
No it does not just stops a restart.
It also activates a stop request with self.stream_list[stream_id]['stop_request'] = True
Yes, and when does the stream stop after activating?
the stream loop in the socket class (own threads) is checking if there is a new request every round.
as mentioned here i want to try a new way to stop streams with loop.close()
.
implementing delete_listen_key_by_stream_id()
makes sense i guess!
delete_stream_from_stream_list()
is not good, because it contains statistics that can help debugging and maybe devs want still have it available.We can implement a frequent_check that cleans the oldest inactive streams if theere are more 1000 entries on the stack.
Yeah, makes sense: delete_listen_key_by_stream_id()
should be enough.
Just for documentation: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/issues/137 depends on the same fix.
I dont know whats the right or working way to solve this. Has someone an idea or a hint?
I dont know whats the right or working way to solve this. Has someone an idea or a hint?
since it awaits here until data is arrived or connection is closed: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/1e57327cf19bdacf280328f98ad5e5bffa7ae449/unicorn_binance_websocket_api/unicorn_binance_websocket_api_connection.py#L290
you can close websocket or use wait_for
@ebp-z thanks for the hint. using wait_for()
has led to restart of the socket after each timeout. i tested wit loop.run_until_complete()
and loop.run_forever()
.
But i found out now, that the loop.stop()
which i tryed in the past, is working with loop.run_forever()
but not with loop.run_until_complete()
what we used till now. i switched it and stop() works now :)
Thanks you!
Check this or we will delete your issue. (fill in the checkbox with an X like so: [x])
Select one:
Environment
What kind of internet connection do you have?
Average system load (CPU)
Hardware specification
Operating System? (include version)
Options
Which endpoint do you connect?
Python Version Requirement
Exact Python Version?
Pip Version?
Dependencies
UNICORN Binance WebSocket API Version?
Description of your issue
stop_stream()
doesn't stop the related stream immediately. As we can see the code just stops restart.https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/blob/c975d49486f93761bbeb01e5a87ff9d4302129f6/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py#L3171
So we need to wait till next
heartbeat/ping-pong
. Maybe this is the design choice but the function name is a little bit confusing then. Maybe we rename it to:stop_restart_stream()
? Or we can implementdelete_listen_key_by_stream_id()
as well asdelete_stream_from_stream_list
in it? Maybe both? Just a suggestion.