fix try/finally with continue, fix wrong subclass signature
This commit is contained in:
parent
3a538d649a
commit
ecdf819088
|
@ -74,7 +74,7 @@ class OpenAIRequestHandler(RequestHandler):
|
|||
# Ratelimited: you are only allowed to have {opts.simultaneous_requests_per_ip} simultaneous requests at a time. Please complete your other requests before sending another.
|
||||
return 'Ratelimited', 429
|
||||
|
||||
def handle_error(self, error_msg: str) -> Tuple[flask.Response, int]:
|
||||
def handle_error(self, error_msg: str, error_type: str = 'error') -> Tuple[flask.Response, int]:
|
||||
# TODO: return a simulated OpenAI error message
|
||||
return jsonify({
|
||||
"error": {
|
||||
|
|
|
@ -16,19 +16,13 @@ def worker():
|
|||
increment_ip_count(client_ip, 'processing_ips')
|
||||
redis.incr('active_gen_workers')
|
||||
|
||||
if not request_json_body:
|
||||
# This was a dummy request from the websocket handler.
|
||||
# We're going to let the websocket handler decrement processing_ips and active_gen_workers.
|
||||
continue
|
||||
|
||||
try:
|
||||
if not request_json_body:
|
||||
# This was a dummy request from the websocket handler.
|
||||
# We're going to let the websocket handler decrement processing_ips and active_gen_workers.
|
||||
continue
|
||||
|
||||
start_time = time.time()
|
||||
success, response, error_msg = generator(request_json_body)
|
||||
end_time = time.time()
|
||||
|
||||
elapsed_time = end_time - start_time
|
||||
# redis.rpush('generation_elapsed', json.dumps((end_time, elapsed_time)))
|
||||
|
||||
event = DataEvent(event_id)
|
||||
event.set((success, response, error_msg))
|
||||
finally:
|
||||
|
|
Reference in New Issue