Closed flenter closed 1 year ago
Adding a note here: Decorating fastapi path operation functions with @autometrics
breaks the API
So, this throws an error:
@app.get("/async-test")
@autometrics
async def async_test_route():
message = await my_async_function()
return {"Hello": message}
But this works:
@app.get("/async-test")
async def async_test_route():
message = await my_async_function()
return {"Hello": message}
Right now the decorator assumes that the function it is wrapping when it returns it is also finished. This is not the case with async functions.
When calling this function it will return quickly but when you use
await
it suddenly takes ~0.1s longer.