Skip to content

Commit

Permalink
small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Oct 27, 2023
1 parent 06e22a4 commit dbddbf7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions atproto/firehose/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _handle_websocket_error_or_stop(exception: Exception) -> bool:
raise FirehoseError from exception


def _get_messageframe_from_bytes_or_raise(data: bytes) -> MessageFrame:
def _get_message_frame_from_bytes_or_raise(data: bytes) -> MessageFrame:
frame = Frame.from_bytes(data)
if isinstance(frame, ErrorFrame):
raise FirehoseError(XrpcError(frame.body.error, frame.body.message))
Expand Down Expand Up @@ -113,8 +113,9 @@ def _get_client(self):
return connect(self._websocket_uri, max_size=_MAX_MESSAGE_SIZE_BYTES)

def _get_async_client(self):
# NOTE: I've noticed that the close operation often takes the entire timeout for some reason
# By default this is 10 seconds, which is pretty long. Maybe shorten it?
# FIXME(DXsmiley): I've noticed that the close operation often takes the entire timeout for some reason
# By default, this is 10 seconds, which is pretty long.
# Maybe shorten it?
return aconnect(self._websocket_uri, max_size=_MAX_MESSAGE_SIZE_BYTES)

def _get_reconnection_delay(self) -> int:
Expand All @@ -130,7 +131,7 @@ def __init__(
) -> None:
super().__init__(method, base_uri, params)

# TODO: Not sure if this should be a Lock or not, the async is using an Event now
# TODO(DXsmiley): Not sure if this should be a Lock or not, the async is using an Event now
self._stop_lock = threading.Lock()

self._on_message_callback: t.Optional[OnMessageCallback] = None
Expand Down Expand Up @@ -181,7 +182,7 @@ def start(
continue

try:
frame = _get_messageframe_from_bytes_or_raise(raw_frame)
frame = _get_message_frame_from_bytes_or_raise(raw_frame)
self._process_message_frame(frame)
except Exception as e: # noqa: BLE001
_handle_frame_decoding_error(e)
Expand Down Expand Up @@ -261,7 +262,7 @@ async def start(
continue

try:
frame = _get_messageframe_from_bytes_or_raise(raw_frame)
frame = _get_message_frame_from_bytes_or_raise(raw_frame)
await self._process_message_frame(frame)
except Exception as e: # noqa: BLE001
_handle_frame_decoding_error(e)
Expand Down

0 comments on commit dbddbf7

Please sign in to comment.