Skip to content

Commit

Permalink
Use get_nowait in event queues
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Jan 13, 2025
1 parent ef7daed commit ea9b757
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ert/ensemble_evaluator/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ def set_event_handler(event_types: set[type[Event]], func: Any) -> None:
):
self._complete_batch.clear()
try:
event = await asyncio.wait_for(self._events.get(), timeout=0.1)
event = self._events.get_nowait()
function = event_handler[type(event)]
batch.append((function, event))
self._events.task_done()
except TimeoutError:
except asyncio.QueueEmpty:
await asyncio.sleep(0.1)
continue
self._complete_batch.set()
await self._batch_processing_queue.put(batch)
Expand Down
2 changes: 1 addition & 1 deletion src/ert/gui/simulation/queue_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def consume_and_emit(self) -> None:
while True:
event = None
with suppress(Empty):
event = self._event_queue.get(timeout=1.0)
event = self._event_queue.get_nowait()
if self._stopped:
logger.debug("stopped")
break
Expand Down

0 comments on commit ea9b757

Please sign in to comment.