Skip to content

Commit 6335150

Browse files
Useless
1 parent 850ed7f commit 6335150

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

src/replit_river/client_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async def _handle_messages_from_ws(self) -> None:
121121
ws_wrapper = self._ws_wrapper
122122
async for message in ws_wrapper.ws:
123123
try:
124-
if not await ws_wrapper.is_open():
124+
if not ws_wrapper.is_open():
125125
# We should not process messages if the websocket is closed.
126126
break
127127
msg = parse_transport_msg(message)

src/replit_river/message_buffer.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def __init__(self, max_num_messages: int = MAX_MESSAGE_BUFFER_SIZE):
2323

2424
async def empty(self) -> bool:
2525
"""Check if the buffer is empty"""
26-
async with self._lock:
27-
return len(self.buffer) == 0
26+
return len(self.buffer) == 0
2827

2928
async def put(self, message: TransportMessage) -> None:
3029
"""Add a message to the buffer. Blocks until there is space in the buffer.
@@ -42,10 +41,9 @@ async def put(self, message: TransportMessage) -> None:
4241

4342
async def peek(self) -> TransportMessage | None:
4443
"""Peek the first message in the buffer, returns None if the buffer is empty."""
45-
async with self._lock:
46-
if len(self.buffer) == 0:
47-
return None
48-
return self.buffer[0]
44+
if len(self.buffer) == 0:
45+
return None
46+
return self.buffer[0]
4947

5048
async def remove_old_messages(self, min_seq: int) -> None:
5149
"""Remove messages in the buffer with a seq number less than min_seq."""

src/replit_river/server_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async def _handle_messages_from_ws(self, tg: asyncio.TaskGroup) -> None:
118118
ws_wrapper = self._ws_wrapper
119119
async for message in ws_wrapper.ws:
120120
try:
121-
if not await ws_wrapper.is_open():
121+
if not ws_wrapper.is_open():
122122
# We should not process messages if the websocket is closed.
123123
break
124124
msg = parse_transport_msg(message)

src/replit_river/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async def is_session_open(self) -> bool:
152152

153153
async def is_websocket_open(self) -> bool:
154154
async with self._ws_lock:
155-
return await self._ws_wrapper.is_open()
155+
return self._ws_wrapper.is_open()
156156

157157
async def _begin_close_session_countdown(self) -> None:
158158
"""Begin the countdown to close session, this should be called when
@@ -276,7 +276,7 @@ async def send_message(
276276
# The session is closed and is no longer accepting new messages.
277277
return
278278
async with self._ws_lock:
279-
if not await self._ws_wrapper.is_open():
279+
if not self._ws_wrapper.is_open():
280280
# If the websocket is closed, we should not send the message
281281
# and wait for the retry from the buffer.
282282
return
@@ -302,7 +302,7 @@ async def close_websocket(
302302
"""Mark the websocket as closed, close the websocket, and retry if needed."""
303303
async with self._ws_lock:
304304
# Already closed.
305-
if not await ws_wrapper.is_open():
305+
if not ws_wrapper.is_open():
306306
return
307307
await ws_wrapper.close()
308308
if should_retry and self._retry_connection_callback:

src/replit_river/websocket_wrapper.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ def __init__(self, ws: WebSocketCommonProtocol) -> None:
2121
self.ws_lock = asyncio.Lock()
2222
self.id = ws.id
2323

24-
async def is_open(self) -> bool:
25-
async with self.ws_lock:
26-
return self.ws_state == WsState.OPEN
24+
def is_open(self) -> bool:
25+
return self.ws_state == WsState.OPEN
2726

2827
async def close(self) -> None:
2928
async with self.ws_lock:

0 commit comments

Comments
 (0)