Fix: RateLimit requests were not released when a streaming generation exception occurred (#11540)

pull/11560/head
liuzhenghua 1 year ago committed by GitHub
parent ceaa9f1101
commit d05f189049
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -110,7 +110,7 @@ class RateLimitGenerator:
raise StopIteration
try:
return next(self.generator)
except StopIteration:
except Exception:
self.close()
raise

@ -108,6 +108,9 @@ class AppGenerateService:
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)

Loading…
Cancel
Save