[Add] ping_interval
增加了一个变量,用来控制websocket_client中ping的时间间隔。
This commit is contained in:
parent
6ce3f64c75
commit
455a1851a7
@ -50,9 +50,10 @@ class WebsocketClient(object):
|
|||||||
self._last_sent_text = None
|
self._last_sent_text = None
|
||||||
self._last_received_text = None
|
self._last_received_text = None
|
||||||
|
|
||||||
def init(self, host: str, proxy_host: str = "", proxy_port: int = 0):
|
def init(self, host: str, proxy_host: str = "", proxy_port: int = 0, ping_interval: int = 60):
|
||||||
""""""
|
""""""
|
||||||
self.host = host
|
self.host = host
|
||||||
|
self.ping_interval = ping_interval # seconds
|
||||||
|
|
||||||
if proxy_host and proxy_port:
|
if proxy_host and proxy_port:
|
||||||
self.proxy_host = proxy_host
|
self.proxy_host = proxy_host
|
||||||
@ -202,7 +203,7 @@ class WebsocketClient(object):
|
|||||||
et, ev, tb = sys.exc_info()
|
et, ev, tb = sys.exc_info()
|
||||||
self.on_error(et, ev, tb)
|
self.on_error(et, ev, tb)
|
||||||
self._reconnect()
|
self._reconnect()
|
||||||
for i in range(60):
|
for i in range(self.ping_interval):
|
||||||
if not self._active:
|
if not self._active:
|
||||||
break
|
break
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user