From 556f6aa1743f28b57cd5da556e3b8e291f7cf47a Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sun, 18 Feb 2024 11:42:40 +1100 Subject: [PATCH] chore(nodes): add comments for cancel state --- .../session_processor/session_processor_default.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/invokeai/app/services/session_processor/session_processor_default.py b/invokeai/app/services/session_processor/session_processor_default.py index dd34c78252..2ff76c06e4 100644 --- a/invokeai/app/services/session_processor/session_processor_default.py +++ b/invokeai/app/services/session_processor/session_processor_default.py @@ -192,9 +192,20 @@ class DefaultSessionProcessor(SessionProcessorBase): ) except KeyboardInterrupt: + # TODO(psyche): should we set the cancel event here and/or cancel the queue item? pass except CanceledException: + # When the user cancels the graph, we first set the cancel event. The event is checked + # between invocations, in this loop. Some invocations are long-running, and we need to + # be able to cancel them mid-execution. + # + # For example, denoising is a long-running invocation with many steps. A step callback + # is executed after each step. This step callback checks if the canceled event is set, + # then raises a CanceledException to stop execution immediately. + # + # When we get a CanceledException, we don't need to do anything - just pass and let the + # loop go to its next iteration, and the cancel event will be handled correctly. pass except Exception as e: