Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix message reading causing OOM on a busy bus #28

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion adafruit_mcp2515/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,12 @@ def unread_message_count(self):
Returns:
int: The unread message count
"""
self._read_from_rx_buffers()

# Wait until the queue is empty before reading from the MCP2515 again,
# otherwise we'll fill it faster than what the user app can process
# and quickly run out of memory.
if len(self._unread_message_queue) == 0:
tannewt marked this conversation as resolved.
Show resolved Hide resolved
self._read_from_rx_buffers()

return len(self._unread_message_queue)

Expand Down
Loading