Websocket Reconnect #12
Unanswered
synodriver
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
当前的实现是,在建立
ws
连接之后,后台会有一个协程负责循环读取数据,与send协程分开,修改前
但是因为网络问题断开后,session会被close,这时只能新实例化一个client_session,来更新self的属性,但是,后台还有个协程在读取self.client_session,他可不知道client_session更新了,因此引入了一个
asyncio.Event
,在断线时启用,同时后台协程wait两个协程,看谁先返回,若是event的那个就该更新自己监听的clientsession修改后
想法是好的,但这显然引入了更多问题,比如event被设置后另一个协程还是不知道之类的,依然卡在https://github.com/synodriver/aioaria2/blob/reconnect/aioaria2/client.py#L847 就很迷
Beta Was this translation helpful? Give feedback.
All reactions