fix(nodes): 100% cpu usage when processor paused

Should be waiting on the resume event instead of checking it in a loop
This commit is contained in:
psychedelicious 2024-04-01 07:45:36 +11:00
parent 1badf0f32f
commit bd9b00a6bf

View File

@ -122,7 +122,8 @@ class DefaultSessionProcessor(SessionProcessorBase):
# Middle processor try block; any unhandled exception is a non-fatal processor error
try:
# If we are paused, wait for resume event
if resume_event.is_set():
resume_event.wait()
# Get the next session to process
self._queue_item = self._invoker.services.session_queue.dequeue()
@ -140,9 +141,7 @@ class DefaultSessionProcessor(SessionProcessorBase):
# Loop over invocations until the session is complete or canceled
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)
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
self._invoker.services.events.emit_invocation_started(
@ -249,9 +248,7 @@ class DefaultSessionProcessor(SessionProcessorBase):
# 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.
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()
# Set the invocation to None to prepare for the next session