Skip to content

Commit

Permalink
Fix: RateLimit requests were not released when a streaming generation…
Browse files Browse the repository at this point in the history
… exception occurred (#11540)
  • Loading branch information
liuzhenghua authored Dec 11, 2024
1 parent ceaa9f1 commit d05f189
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/core/app/features/rate_limiting/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __next__(self):
raise StopIteration
try:
return next(self.generator)
except StopIteration:
except Exception:
self.close()
raise

Expand Down
3 changes: 3 additions & 0 deletions api/services/app_generate_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def generate(
raise ValueError(f"Invalid app mode {app_model.mode}")
except RateLimitError as e:
raise InvokeRateLimitError(str(e))
except Exception:
rate_limit.exit(request_id)
raise
finally:
if not streaming:
rate_limit.exit(request_id)
Expand Down

0 comments on commit d05f189

Please sign in to comment.