mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-14 04:09:09 +00:00
fix(streaming): annotate the three intentional blind excepts
`ruff_strict_gate.py` counts BLE001 against a ceiling taken at the merge-base, and the abandoned-stream cleanup path added three: - around `stream_chunk_builder` — a failure here means the partial call cannot be assembled, and it is already logged rather than raised; - around closing the provider stream — must not mask the caller's own error; - in `__del__` — a finalizer must never raise, and the logging is best-effort. Each is suppressed with that reason, matching the existing `# noqa: BLE001` usages elsewhere in litellm. The file's BLE001 count is back to the merge-base baseline (48 -> 48).
This commit is contained in:
parent
e8f0bfd9b9
commit
d745030539
1 changed files with 3 additions and 3 deletions
|
|
@ -332,7 +332,7 @@ class CustomStreamWrapper:
|
|||
logging_obj=self.logging_obj,
|
||||
count_prompt_tokens=self.count_prompt_tokens,
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 # an abandoned stream must still emit whatever telemetry was built; the failure is logged, not raised
|
||||
verbose_logger.warning(
|
||||
"stream_chunk_builder raised for an abandoned stream (%s); the partial call is not logged.",
|
||||
str(e),
|
||||
|
|
@ -378,7 +378,7 @@ class CustomStreamWrapper:
|
|||
if stream_to_close is not None and hasattr(stream_to_close, "close"): # pyright: ignore[reportUnknownArgumentType] # provider-specific stream object
|
||||
try:
|
||||
stream_to_close.close() # pyright: ignore[reportUnknownMemberType] # provider-specific stream object
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 # closing a provider stream must not mask the caller's own error
|
||||
verbose_logger.debug("closing the underlying stream failed: %s", str(e))
|
||||
self._restore_consumer_correlation_context()
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ class CustomStreamWrapper:
|
|||
self._restore_consumer_correlation_context(guarded=True)
|
||||
try:
|
||||
self._flush_abandoned_stream_logging()
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 # __del__ must never raise; logging here is best-effort
|
||||
verbose_logger.debug("abandoned-stream logging failed in __del__", exc_info=True)
|
||||
|
||||
async def aclose(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue