Skip to content

Commit

Permalink
Streaming: Use different errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed Sep 10, 2024
1 parent 49fb4e4 commit a304d6f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mytoolit/can/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@
# -- Classes ------------------------------------------------------------------


class StreamingTimeoutError(Exception):
class StreamingError(Exception):
"""General exception for streaming errors"""


class StreamingTimeoutError(StreamingError):
"""Raised if no streaming data was received for a certain amount of time"""


class StreamingBufferError(StreamingError):
"""Raised if there are too many streaming messages in the buffer"""


# pylint: disable=too-few-public-methods


Expand Down Expand Up @@ -238,7 +246,7 @@ def __init__(
max_buffer_size:
Maximum amount of buffered messages kept by the stream buffer.
If this amount is exceeded, then this listener will raise a
`StreamingTimeoutError`. A large buffer indicates that the
`StreamingBufferError`. A large buffer indicates that the
application is not able to keep up with the current rate of
retrieved messages and therefore the probability of losing
messages is quite high.
Expand Down Expand Up @@ -288,7 +296,7 @@ async def __anext__(self) -> Tuple[StreamingData, int]:
"""

if self.queue.qsize() > self.max_buffer_size:
raise StreamingTimeoutError(
raise StreamingBufferError(
f"Maximum buffer size of {self.max_buffer_size} messages "
"exceeded"
)
Expand Down

0 comments on commit a304d6f

Please sign in to comment.