mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-20 00:11:27 +00:00
fix(stream): reject non-positive timeout env values
_float_env now falls back to default when parsed value is <= 0. asyncio.wait_for with a 0 or negative timeout would fail immediately every call, silently disabling the resume log — misconfiguration now degrades to default behavior with a warning instead.
This commit is contained in:
parent
72429ea8c0
commit
654e958ad5
1 changed files with 8 additions and 2 deletions
|
|
@ -185,15 +185,21 @@ RESUME_STREAM_TTL_REFRESH_EVERY = 64
|
|||
# Replay read timeout: looser since a resume is user-blocking anyway
|
||||
# and silent timeout here is worse than a brief extra wait. Both
|
||||
# configurable for infra where Redis isn't colocated.
|
||||
def _float_env(name: str, default: float) -> float:
|
||||
def _float_env(name: str, default: float, minimum: float = 0.0) -> float:
|
||||
val = os.environ.get(name)
|
||||
if val is None or val == '':
|
||||
return default
|
||||
try:
|
||||
return float(val)
|
||||
parsed = float(val)
|
||||
except (TypeError, ValueError):
|
||||
log.warning(f'Invalid {name}={val!r}; using default {default}')
|
||||
return default
|
||||
if parsed <= minimum:
|
||||
log.warning(
|
||||
f'{name}={parsed} is not positive (must be > {minimum}); using default {default}'
|
||||
)
|
||||
return default
|
||||
return parsed
|
||||
|
||||
|
||||
RESUME_STREAM_REDIS_TIMEOUT_SEC = _float_env('RESUME_STREAM_REDIS_TIMEOUT_SEC', 0.1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue