I am getting an issue with websocket. Any example I run from https://github.com/Binance-docs/binance-futures-connector-python/tree/main/examples/websocket/futures gives me the following error - "WARNING:root:WebSocket connection closed: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake), code: 1006, clean: False, reason: connection was closed uncleanly (peer dropped the TCP connection without previous WebSocket closing handshake)".
Whenever I try to rerun the examples I get the error "error.ReactorNotRestartable()
twisted.internet.error.ReactorNotRestartable".
I have found out that I can escape this error by uninstalling and then reinstalling the twisted library. But then I have to repeat the reinstallment every time I want to start the websocket. Since this isn't a feasible solution. Can someone here help me with how to resolve this issue? What would be the most appropriate way to close the websocket connection since
ws_client = FuturesWebsocketClient(), ws_client.stop()
is causing this issue.
发布评论
评论(2)
扭曲的反应堆目前不可重新启动。您最多可以安装每个过程,最多可以运行一次。
您的Jupyer笔记本电脑正在以一个长期寿命的Python过程中运行,因此您仅限于您正在尝试的任何运行反应器互动。
我不知道您的意思是“卸载和重新安装扭曲”,但是一般的解决方案是安排您的代码,这样您只需要运行一次扭曲的反应堆(即,在完成所有操作之前就不要停止它您想做)或为扭曲的可重启反应堆贡献。
或者,也许,停止在jupyter笔记本中运行代码,然后将其运行,以不同的过程使用寿命。
Twisted's reactors are presently not restartable. You can install at most one per process and you can run it at most once.
Your Jupyer notebook is running in a single long-lived Python process so you are limited to a single of whatever run-the-reactor interaction you are attempting.
I don't know what you mean by "uninstalling and reinstalling Twisted" but the general solution is to arrange your code so that you only need to run a Twisted reactor once (ie, don't stop it before you're done with everything you want to do) or contribute restartable reactors to Twisted.
Or, perhaps, stop running your code in a Jupyter Notebook and run it in something with a different process lifetime instead.
请尝试使用最新版本,Websocket部分已重新设计。
Please have a try with the latest version, the Websocket part has been redesigned.