Skip to content

Commit a3e66cc

Browse files
committed
ws improvements
1 parent d0bb054 commit a3e66cc

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

thingsdb/client/wsprotocol.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ async def connect(self, uri, ssl: SSLContext | None):
3333

3434
async def _recv_loop(self):
3535
try:
36-
while True:
37-
data: bytes = await self._proto.recv() # type: ignore
36+
while self._proto:
37+
data: bytes = await self._proto.recv(decode=False)
3838
pkg = None
3939
try:
4040
pkg = Package(data)
@@ -50,34 +50,35 @@ async def _recv_loop(self):
5050

5151
except ConnectionClosed as exc:
5252
self.cancel_requests()
53-
self._proto = None # type: ignore
53+
self._proto = None
5454
self._on_connection_lost(self, exc) # type: ignore
5555

5656
def _write(self, data: Any):
5757
if self._proto is None:
5858
raise ConnectionError('no connection')
59-
asyncio.create_task(self._proto.send(data)) # type: ignore
59+
asyncio.create_task(self._proto.send(data))
6060

6161
def close(self):
6262
self._is_closing = True
6363
if self._proto:
64-
asyncio.create_task(self._proto.close()) # type: ignore
64+
asyncio.create_task(self._proto.close())
6565

6666
def is_closing(self) -> bool:
6767
return self._is_closing
6868

6969
async def wait_closed(self):
7070
if self._proto:
71-
await self._proto.wait_closed() # type: ignore
71+
await self._proto.wait_closed()
7272

7373
async def close_and_wait(self):
7474
if self._proto:
75-
await self._proto.close() # type: ignore
75+
await self._proto.close()
7676

7777
def info(self) -> Any:
78-
return self._proto.transport.get_extra_info( # type: ignore
79-
'socket',
80-
None)
78+
if self._proto:
79+
return self._proto.transport.get_extra_info(
80+
'socket',
81+
None)
8182

8283
def is_connected(self) -> bool:
8384
return self._proto is not None

thingsdb/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.0'
1+
__version__ = '1.3.1'

0 commit comments

Comments
 (0)