Skip to content

Commit

Permalink
Merge pull request #90 from khauersp/feature/fill-in-missing-timeout
Browse files Browse the repository at this point in the history
fill in missing timeouts
  • Loading branch information
snideto authored Oct 9, 2024
2 parents 2eef93c + 88bba65 commit e830359
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions j1939/Dm14Query.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,15 @@ def read(
self._send_dm14(7)
self.state = QueryState.WAIT_FOR_SEED
# wait for operation completed DM15 message
raw_bytes = self.data_queue.get(block=True, timeout=1)
raw_bytes = None
try:
raw_bytes = self.data_queue.get(block=True, timeout=max_timeout)
except queue.Empty:
if self.state is QueryState.WAIT_FOR_SEED:
raise RuntimeError("No response from server")
pass
for _ in range(self.exception_queue.qsize()):
raise self.exception_queue.get(block=False, timeout=1)
raise self.exception_queue.get(block=False, timeout=max_timeout)
if raw_bytes:
if self.return_raw_bytes:
return raw_bytes
Expand Down Expand Up @@ -282,7 +288,7 @@ def write(
try:
self.data_queue.get(block=True, timeout=max_timeout)
for _ in range(self.exception_queue.qsize()):
raise self.exception_queue.get(block=False, timeout=1)
raise self.exception_queue.get(block=False, timeout=max_timeout)
except queue.Empty:
if self.state is QueryState.WAIT_FOR_SEED:
raise RuntimeError("No response from server")
Expand Down
2 changes: 1 addition & 1 deletion test/test_memory_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def test_dm14_read_timeout_error(feeder):
Tests that the DM14 read query can react to timeout errors correctly
:param feeder: can message feeder
"""
with pytest.raises(queue.Empty) as excinfo:
with pytest.raises(RuntimeError) as excinfo:
feeder.can_messages = [
(
Feeder.MsgType.CANTX,
Expand Down

0 comments on commit e830359

Please sign in to comment.