Boosted by glyph ("Glyph"):
encthenet@flyovercountry.social ("John-Mark Gurney") wrote:
I'm seeing some weird behavior with FastAPI and async.
I have a function:
```
async def foo(r=[]):
if r: return r[0]
r.append(someobj())
return r[0]
```Now I have that declared on a route via the usual:
```
@router.get('/somepage')
async def get_somepage(foo : Annotated[someobj, Depends(foo)]):
xxx
```But in the foo function, I print the id of the r list, and each time somepage is fetched, the list is different.
I did finally just move r into the module name space, and that fixed things. But it's pretty clear that FastAPI is doing something wonky with function calls.