Hi team, the doc tells I should create gb instance...
# ask-questions
f
Hi team, the doc tells I should create gb instance for each request in web framework, but there're deep callstack after request entrypoint. Pass gb as parameter is not elegant, is there any better practice? btw, my project is based on fastapi. Thanks!
r
Hi. You're right that we recommend creating a new instance for each request in server-side implementations. Can you say more about what's causing the inelegance? Is it a limitation of the FastAPI framework?
f
Hi @strong-mouse-55694, there are deep call stacks, so I have to pass gb instance layer by layer such I can use gb in inner function. If it's a multiple thread framework, I can use python ContextVar to use gb like a global variable, but the fastapi is based on event loop. So, is there any easier way to use?
r
I'm checking with the team to see if they have any other ideas.
Thanks for waiting. I chatted with the team. Right now, there isn't another way to do this., However, your question/request has come in regards to other SDKs, too, so it's something that is on the dev team's mind. I've passed on your feedback to them.
👍 1