I am doing predictions with FastApi using background workers. Everything seems working but if I warp the background worker function in another function and call it then it's not working. Why does this is happening? It is obvious to work right. Do background workers in fastapi won't work i do pass the function this way?
# this is the working example
@app.get(api_names[0])
async def predict(background_tasks: BackgroundTasks,solute,solvent):
background_tasks.add_task(predictions,solute,solvent)
return {'success'}
# but when i change the above end point to below its not working
@app.get(api_names[0])
async def predict(background_tasks: BackgroundTasks,solute,solvent):
sample = predict_dup(0)
background_tasks.add_task(sample,solute,solvent)
return {'success'}
async def predict_dup(task_id):
if task_id == 0:
return predictions
elif task_id == 2:
return predictions_two