diff --git a/__init__.py b/__init__.py index 41c6fba7..7482e606 100644 --- a/__init__.py +++ b/__init__.py @@ -120,6 +120,7 @@ except Exception as e: logger = get_logger("prompt_manager.init") logger.error(f"Failed to register API routes: {e}") except Exception: + # logging failed too; a report must never stop the node loading pass # Shared database, set up with the monitoring system below. Stays None when that @@ -411,6 +412,7 @@ except Exception as e: f"Failed to register the exit signal: {e}" ) except Exception: + # logging failed too; a report must never stop the node loading pass try: @@ -428,6 +430,7 @@ except Exception as e: f"Failed to register the background work teardown: {e}" ) except Exception: + # logging failed too; a report must never stop the node loading pass __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"] diff --git a/database/library_move.py b/database/library_move.py index 91dc7274..c104ac15 100644 --- a/database/library_move.py +++ b/database/library_move.py @@ -590,6 +590,7 @@ class _Move: try: os.rmdir(self.plan.target_dir) except OSError: + # not empty or already gone: the undo leaves it alone pass diff --git a/database/safety_backup.py b/database/safety_backup.py index ad212a14..5ce36619 100644 --- a/database/safety_backup.py +++ b/database/safety_backup.py @@ -46,6 +46,7 @@ def remove_quietly(*paths): if path and os.path.exists(path): os.remove(path) except OSError: + # cleanup after a failure must not replace that failure pass diff --git a/py/api/admin.py b/py/api/admin.py index 0d4df16d..3488a056 100644 --- a/py/api/admin.py +++ b/py/api/admin.py @@ -539,6 +539,7 @@ def _diagnose_output_dirs(configured_dirs, public_path=None): candidates.append(folder_paths.get_output_directory()) except ImportError: + # outside ComfyUI there is no output folder to add pass output_dirs = [] diff --git a/py/api/images.py b/py/api/images.py index 2ded1782..519f3751 100644 --- a/py/api/images.py +++ b/py/api/images.py @@ -396,6 +396,7 @@ def _video_placeholder_image(thumbnail_size): font=font, ) except (OSError, AttributeError): + # a placeholder without its label still works pass return img @@ -499,6 +500,7 @@ def _preview_names(folders, folder): except OSError: continue except OSError: + # an unreadable folder lists as empty; nothing there to cache pass folders[folder] = names return names diff --git a/py/api/library_location.py b/py/api/library_location.py index d601f00d..17d172c7 100644 --- a/py/api/library_location.py +++ b/py/api/library_location.py @@ -207,6 +207,7 @@ class LibraryLocationRoutesMixin: try: size = os.path.getsize(location.db_path) except OSError: + # no library file yet: report size 0 pass return { "path": self._library_public_path(location.db_path), diff --git a/py/api/lora_integration.py b/py/api/lora_integration.py index 3531d4a2..86370f5b 100644 --- a/py/api/lora_integration.py +++ b/py/api/lora_integration.py @@ -536,6 +536,7 @@ class LoraIntegrationMixin: except asyncio.CancelledError: interrupted = True except Exception: + # the await after this loop raises it for the caller pass if interrupted: raise asyncio.CancelledError diff --git a/py/api/thumbnail_auto.py b/py/api/thumbnail_auto.py index 05af0c2d..5cd662b7 100644 --- a/py/api/thumbnail_auto.py +++ b/py/api/thumbnail_auto.py @@ -533,6 +533,7 @@ class AutoThumbnailer: try: process.kill() except OSError: + # the process has already exited pass if worker is None: return True diff --git a/py/api/thumbnail_encode.py b/py/api/thumbnail_encode.py index bcbee3ef..f7a6ca54 100644 --- a/py/api/thumbnail_encode.py +++ b/py/api/thumbnail_encode.py @@ -158,6 +158,7 @@ def _unlink_quietly(path): try: Path(path).unlink() except FileNotFoundError: + # already gone, which is what was wanted pass except OSError as exc: logger.debug(f"Could not remove temp file {Path(path).name}: {exc}") @@ -221,6 +222,7 @@ def shutdown_encoders(): try: process.kill() except OSError: + # the process has already exited pass @@ -359,10 +361,12 @@ def thumbnail_frame(img, edge): try: img.seek(0) except (EOFError, AttributeError, ValueError): + # not seekable or a single frame: use the current one pass try: img.draft("RGB", (edge, edge)) # JPEG: decode at a reduced scale except (AttributeError, ValueError, OSError): + # draft is only a speedup; the full decode below still works pass frame = img.convert("RGB") if img.mode != "RGB" else img.copy() frame.thumbnail((edge, edge), Image.Resampling.LANCZOS) diff --git a/py/config_store.py b/py/config_store.py index 949423a3..0664f026 100644 --- a/py/config_store.py +++ b/py/config_store.py @@ -109,6 +109,7 @@ def _write_atomically(path: str, payload: bytes) -> None: try: os.unlink(temp_path) except OSError: + # nothing to clean up; the original error is raised below pass raise diff --git a/py/lora_manager_layout.py b/py/lora_manager_layout.py index d05abe59..dba820b3 100644 --- a/py/lora_manager_layout.py +++ b/py/lora_manager_layout.py @@ -642,6 +642,7 @@ def layout_summary(layout: LoraManagerLayout, home: Path) -> Dict: relative = Path(settings_file).relative_to(home) settings_file = os.path.join("~", str(relative)) except ValueError: + # outside the home folder: show the full path pass return { "source": layout.source, diff --git a/py/lora_utils.py b/py/lora_utils.py index da71a3c9..4c8f6de2 100644 --- a/py/lora_utils.py +++ b/py/lora_utils.py @@ -585,6 +585,7 @@ def _read_capped(resp, cap: int) -> Optional[bytes]: if int(declared) > cap: return None except ValueError: + # a bad header says nothing; the read below enforces the cap pass chunks = [] @@ -707,6 +708,7 @@ def _save_atomically(image, local_path: Path) -> None: try: os.remove(temp) except OSError: + # nothing to clean up; the original error is raised below pass raise diff --git a/tests/browser/slow_reset_watch.py b/tests/browser/slow_reset_watch.py index e3b453b6..3ff6a85f 100644 --- a/tests/browser/slow_reset_watch.py +++ b/tests/browser/slow_reset_watch.py @@ -109,6 +109,7 @@ class ResetWatch: stream.write(text) stream.flush() except (OSError, ValueError): + # the stream closed; a watcher must not fail the server pass diff --git a/tests/test_library_location_wiring.py b/tests/test_library_location_wiring.py index d2fa31af..a0087b30 100644 --- a/tests/test_library_location_wiring.py +++ b/tests/test_library_location_wiring.py @@ -135,6 +135,7 @@ class TestLogsAndCache(_EnvCase): get_logger_manager()._setup_loggers() except Exception: + # best effort restore in teardown; must not hide the test result pass def test_lora_image_cache_follows_the_data_folder(self): diff --git a/utils/execution_history_writer.py b/utils/execution_history_writer.py index 248b49de..715bfdad 100644 --- a/utils/execution_history_writer.py +++ b/utils/execution_history_writer.py @@ -398,6 +398,7 @@ class HistoryWriter: try: command = self._queue.get_nowait() except queue.Empty: + # no command waiting; the loop below handles command None pass if probe: try: diff --git a/utils/image_monitor.py b/utils/image_monitor.py index 5b016c7b..452bf104 100644 --- a/utils/image_monitor.py +++ b/utils/image_monitor.py @@ -1048,8 +1048,8 @@ class ImageGenerationHandler(FileSystemEventHandler): with Image.open(image_path) as img: file_info["dimensions"] = list(img.size) file_info["format"] = img.format - except Exception: - pass + except Exception as error: + self.logger.debug(f"No dimensions for {image_path}: {error}") return file_info except Exception as e: @@ -1424,8 +1424,8 @@ class ImageMonitor: if self.observer is not None: try: observer_alive = self.observer.is_alive() - except Exception: - pass + except Exception as error: + self.logger.debug(f"Could not read the observer state: {error}") return { "running": self.observer is not None, "monitored_directories": self.monitored_directories, diff --git a/utils/library_location.py b/utils/library_location.py index 4a69b6ab..0e637992 100644 --- a/utils/library_location.py +++ b/utils/library_location.py @@ -466,6 +466,7 @@ def ensure_private_dir(path: str) -> str: try: os.chmod(path, 0o700) except OSError: + # the folder exists; a filesystem without modes keeps its own pass return path diff --git a/utils/media_capture.py b/utils/media_capture.py index b826bc85..c978305b 100644 --- a/utils/media_capture.py +++ b/utils/media_capture.py @@ -181,6 +181,7 @@ def _unlink_quietly(path: str) -> None: try: os.unlink(path) except FileNotFoundError: + # already gone, which is what was wanted pass except OSError as error: logger.warning("Capture file %s could not be removed: %s", path, error) @@ -390,6 +391,7 @@ class CaptureStore: try: os.rmdir(self.directory) except FileNotFoundError: + # already gone, which is what was wanted pass except OSError as error: logger.warning( diff --git a/utils/trash.py b/utils/trash.py index 7fcf5121..309c6207 100644 --- a/utils/trash.py +++ b/utils/trash.py @@ -339,6 +339,7 @@ class FreedesktopBackend: try: os.mkdir(name, 0o700, dir_fd=parent_fd) except FileExistsError: + # the folder already exists; the checks below still vet it pass except OSError as error: raise TrashRefused(NO_TRASH, str(error)) from error diff --git a/utils/trash_macos.py b/utils/trash_macos.py index 4ce422da..0a7644a6 100644 --- a/utils/trash_macos.py +++ b/utils/trash_macos.py @@ -114,6 +114,7 @@ def inside_any_root(path: str, roots) -> bool: if _identity(current) in identities: return True except OSError: + # an unreadable folder cannot be a trash; try its parent pass parent = os.path.dirname(current) if parent == current: diff --git a/utils/workspace_keys.py b/utils/workspace_keys.py index 5087c53b..cdc37ab6 100644 --- a/utils/workspace_keys.py +++ b/utils/workspace_keys.py @@ -88,6 +88,7 @@ def _unlink(path: str) -> None: try: os.unlink(path) except OSError: + # best effort cleanup; the next sweep removes a leftover temp pass @@ -105,6 +106,7 @@ def _sweep_temps(directory: str) -> None: if os.stat(path).st_mtime < cutoff: os.unlink(path) except OSError: + # best effort: a later sweep removes what this one could not pass @@ -116,6 +118,7 @@ def _tighten(path: str) -> None: if stat.S_IMODE(os.stat(path).st_mode) & 0o077: os.chmod(path, 0o600) except OSError: + # best effort: the key still works with its old mode pass