[Mod] WebSocketClient: remove useless lock.

This commit is contained in:
nanoric 2019-03-15 03:00:28 -04:00
parent 49e721844e
commit f6d0cda6ce

View File

@ -107,13 +107,17 @@ class WebsocketClient(object):
""" """
Send a text string to server. Send a text string to server.
""" """
return self._get_ws().send(text, opcode=websocket.ABNF.OPCODE_TEXT) ws = self._ws
if ws:
ws.send(text, opcode=websocket.ABNF.OPCODE_TEXT)
def _send_binary(self, data: bytes): def _send_binary(self, data: bytes):
""" """
Send bytes data to server. Send bytes data to server.
""" """
return self._get_ws()._send_binary(data) ws = self._ws
if ws:
ws._send_binary(data)
def _reconnect(self): def _reconnect(self):
"""""" """"""
@ -143,11 +147,6 @@ class WebsocketClient(object):
self._ws.close() self._ws.close()
self._ws = None self._ws = None
def _get_ws(self):
""""""
with self._ws_lock:
return self._ws
def _run(self): def _run(self):
""" """
Keep running till stop is called. Keep running till stop is called.
@ -158,7 +157,7 @@ class WebsocketClient(object):
# todo: onDisconnect # todo: onDisconnect
while self._active: while self._active:
try: try:
ws = self._get_ws() ws = self._ws
if ws: if ws:
text = ws.recv() text = ws.recv()
@ -215,7 +214,7 @@ class WebsocketClient(object):
def _ping(self): def _ping(self):
"""""" """"""
ws = self._get_ws() ws = self._ws
if ws: if ws:
ws.send("ping", websocket.ABNF.OPCODE_PING) ws.send("ping", websocket.ABNF.OPCODE_PING)