File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
model-engine/model_engine_server Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,11 @@ def _get_broker_endpoint_and_transport_options(
476
476
# Going to try this with defaults first.
477
477
out_broker_transport_options ["region" ] = os .environ .get ("AWS_REGION" , "us-west-2" )
478
478
479
+ # changing wait_time_seconds from the default of 10 based on https://github.com/celery/celery/discussions/7283
480
+ # goal is to prevent async requests from being stuck in pending when workers die; the hypothesis is that this is caused by SQS long polling
481
+ out_broker_transport_options ["wait_time_seconds" ] = 0
482
+ out_broker_transport_options ["polling_interval" ] = 5
483
+
479
484
# NOTE: The endpoints should ideally use predefined queues. However, the sender probably needs the flexibility
480
485
# of not requiring predefined queues.
481
486
# assert (
Original file line number Diff line number Diff line change 3
3
"""
4
4
import argparse
5
5
import subprocess
6
+ import time
6
7
7
8
from fastapi import FastAPI , Request
8
9
from fastapi .responses import JSONResponse
@@ -19,7 +20,10 @@ def healthcheck():
19
20
20
21
@app .post ("/predict" )
21
22
async def predict (request : Request ):
22
- return await request .json ()
23
+ dictionary = await request .json ()
24
+ if "delay" in dictionary :
25
+ time .sleep (dictionary ["delay" ])
26
+ return dictionary
23
27
24
28
25
29
@app .post ("/predict500" )
You can’t perform that action at this time.
0 commit comments