fix(quality): say why each empty except is safe, log the broad ones
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -533,6 +533,7 @@ class AutoThumbnailer:
|
||||
try:
|
||||
process.kill()
|
||||
except OSError:
|
||||
# the process has already exited
|
||||
pass
|
||||
if worker is None:
|
||||
return True
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user