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

Debug queue #11

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 13 additions & 2 deletions lcm_websocket_server/lcmpubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class LCMObserver:
def __init__(self, channel_regex: str = ".*"):
self._queue = queue.Queue()
self._channel_regex = channel_regex


self._put_counter = 0
self._get_counter = 0

def match(self, channel: str) -> bool:
"""
Check if the observer matches a given channel.
Expand All @@ -39,12 +42,20 @@ def handle(self, event):
"""
Handle an LCM event.
"""
if self._put_counter % 1000 == 0:
qsize = self._queue.qsize()
logger.info(f"PUT called {self._put_counter} times {qsize=}")
self._put_counter += 1
self._queue.put(event)

def get(self, *args, **kwargs):
"""
Gets the next event from the queue.
"""
if self._get_counter % 1000 == 0:
qsize = self._queue.qsize()
logger.info(f"GET called {self._get_counter} times {qsize=}")
self._get_counter += 1
return self._queue.get(*args, **kwargs)

def task_done(self):
Expand Down