refactor if/else logic slightly

This commit is contained in:
Lincoln Stein 2024-03-31 11:53:18 -04:00 committed by Kent Keirsey
parent 3c9c58e0fa
commit 1badf0f32f

View File

@ -126,11 +126,7 @@ class DefaultSessionProcessor(SessionProcessorBase):
# Get the next session to process # Get the next session to process
self._queue_item = self._invoker.services.session_queue.dequeue() self._queue_item = self._invoker.services.session_queue.dequeue()
if self._queue_item is None: if self._queue_item is not None:
# Empty queue, wait for next polling interval or event to try again
poll_now_event.wait(self._polling_interval)
continue
self._invoker.services.logger.debug(f"Executing queue item {self._queue_item.item_id}") self._invoker.services.logger.debug(f"Executing queue item {self._queue_item.item_id}")
cancel_event.clear() cancel_event.clear()
@ -144,7 +140,9 @@ class DefaultSessionProcessor(SessionProcessorBase):
# Loop over invocations until the session is complete or canceled # Loop over invocations until the session is complete or canceled
while self._invocation is not None and not cancel_event.is_set(): while self._invocation is not None and not cancel_event.is_set():
# get the source node id to provide to clients (the prepared node id is not as useful) # get the source node id to provide to clients (the prepared node id is not as useful)
source_invocation_id = self._queue_item.session.prepared_source_mapping[self._invocation.id] source_invocation_id = self._queue_item.session.prepared_source_mapping[
self._invocation.id
]
# Send starting event # Send starting event
self._invoker.services.events.emit_invocation_started( self._invoker.services.events.emit_invocation_started(
@ -251,7 +249,9 @@ class DefaultSessionProcessor(SessionProcessorBase):
# We'll get a GESStatsNotFoundError if we try to log stats for an untracked graph, but in the processor # We'll get a GESStatsNotFoundError if we try to log stats for an untracked graph, but in the processor
# we don't care about that - suppress the error. # we don't care about that - suppress the error.
with suppress(GESStatsNotFoundError): with suppress(GESStatsNotFoundError):
self._invoker.services.performance_statistics.log_stats(self._queue_item.session.id) self._invoker.services.performance_statistics.log_stats(
self._queue_item.session.id
)
self._invoker.services.performance_statistics.reset_stats() self._invoker.services.performance_statistics.reset_stats()
# Set the invocation to None to prepare for the next session # Set the invocation to None to prepare for the next session