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(
476476 # Going to try this with defaults first.
477477 out_broker_transport_options ["region" ] = os .environ .get ("AWS_REGION" , "us-west-2" )
478478
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+
479484 # NOTE: The endpoints should ideally use predefined queues. However, the sender probably needs the flexibility
480485 # of not requiring predefined queues.
481486 # assert (
Original file line number Diff line number Diff line change 33"""
44import argparse
55import subprocess
6+ import time
67
78from fastapi import FastAPI , Request
89from fastapi .responses import JSONResponse
@@ -19,7 +20,10 @@ def healthcheck():
1920
2021@app .post ("/predict" )
2122async 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
2327
2428
2529@app .post ("/predict500" )
You can’t perform that action at this time.
0 commit comments