Skip to content

Commit

Permalink
timeout after waiting for a TestdataProducer response for 10 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
mgor committed Nov 9, 2024
1 parent f6ff0aa commit 18a6a17
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions grizzly/testdata/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def keystore_pop(self, key: str, wait: int = -1) -> str:
start = perf_counter()
while value is None:
gsleep(self.poll_interval)
value = self._keystore_pop_poll(request)
with suppress(Exception):
value = self._keystore_pop_poll(request)

if value is None and wait > -1 and (int(perf_counter() - start) > wait):
error_message = f'no message received within {wait} seconds'
Expand Down Expand Up @@ -251,12 +252,11 @@ def _request(self, request: dict[str, str]) -> dict[str, Any] | None:
self.runner.send_message('produce_testdata', {'uid': uid, 'cid': self.runner.client_id, 'request': request})

# waits for async result
response = cast(Optional[dict[str, Any]], self._responses[uid].get())

# remove request as pending
del self._responses[uid]

return response
try:
return cast(Optional[dict[str, Any]], self._responses[uid].get(timeout=10.0))
finally:
# remove request as pending
del self._responses[uid]


class TestdataProducer:
Expand Down

0 comments on commit 18a6a17

Please sign in to comment.