ComfyUI/comfy/interruption.py
doctorpangloss 341c9f2e90 Improvements to node loading, node API, folder paths and progress
- Improve node loading order. It now occurs "as late as possible".
   Configuration should be exposed as per the README.
 - Added methods to specify custom folders and models used in examples
   more robustly for custom nodes.
 - Downloading models can now be gracefully interrupted.
 - Progress notifications are now sent over the network for distributed
   ComfyUI operations.
 - Python objects have been moved around to prevent less transitive
   package importing issues.
2024-03-13 16:14:18 -07:00

32 lines
815 B
Python

import threading
_interrupt_processing_mutex = threading.RLock()
_interrupt_processing = False
class InterruptProcessingException(Exception):
pass
def interrupt_current_processing(value=True):
global _interrupt_processing
global _interrupt_processing_mutex
with _interrupt_processing_mutex:
_interrupt_processing = value
def processing_interrupted():
global _interrupt_processing
global _interrupt_processing_mutex
with _interrupt_processing_mutex:
return _interrupt_processing
def throw_exception_if_processing_interrupted():
global _interrupt_processing
global _interrupt_processing_mutex
with _interrupt_processing_mutex:
if _interrupt_processing:
_interrupt_processing = False
raise InterruptProcessingException()