Closed virajkanwade closed 5 months ago
Thanks @virajkanwade , this PR needs to add tests:
One question: In our e2e test, we already run fastapi server using uvicorn app:app
, and it works fine (see here). So i wonder why you ran into an issue?
One question: In our e2e test, we already run fastapi server using
uvicorn app:app
, and it works fine (see here). So i wonder why you ran into an issue?
something very specific to how I am setting it up
def create_app():
# $ export SUPERTOKENS_NEST_ASYNCIO=1
sync(supertokens_init())
sync(supertokens_multitenancy_setup_personal())
sync(supertokens_multitenancy_setup_school())
app = FastAPI()
app.add_middleware(get_middleware())
where the multitenancy setup functions call create_or_update_tenant and create_or_update_third_party_config.
What are the import statements that you have used for the functions from our lib?
What are the import statements that you have used for the functions from our lib?
I had tried
from supertokens_python.recipe.multitenancy.syncio import (
create_or_update_tenant,
create_or_update_third_party_config,
)
Right. So why do you need to wrap them with sync()
?
Right. So why do you need to wrap them with
sync()
?
The syncio functions gave the "loop already running" error.
So I followed the code to see the difference between syncio and asyncio functions, and found supertokens sync function.
Then did the whol research above and created my own sync function, hence the sync calls you are seeing in the snippet.
One question: In our e2e test, we already run fastapi server using
uvicorn app:app
, and it works fine (see here). So i wonder why you ran into an issue?
@rishabhpoddar If I run it as
uvicorn --factory main:create_app
I get
RuntimeError: this event loop is already running.
If I run it as
if __name__ == '__main__':
import uvicorn
uvicorn.run(
create_app(),
)
python main.py
it seems to work with the supertokens syncio functions
I see. Okay! Thanks for the info. We can continue working on this PR, in a few weeks, to add more tests (as described in my previous comment).
Not merging this. The right way to use it is described in this issue - https://github.com/supertokens/supertokens-python/issues/501
Summary of change
(A few sentences about this PR)
Related issues
501
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
Documentation changes
(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)
Checklist for important updates
coreDriverInterfaceSupported.json
file has been updated (if needed)supertokens_python/constants.py
frontendDriverInterfaceSupported.json
file has been updated (if needed)setup.py
supertokens_python/constants.py
git tag
) in the formatvX.Y.Z
, and then find the latest branch (git branch --all
) whoseX.Y
is greater than the latest released tag.supertokens_python/utils.py
file to include that in theFRAMEWORKS
variablesyncio
/asyncio
functions are consistent.tests/sessions/test_access_token_version.py
to account for any new claims that are optional or omitted by the coreRemaining TODOs for this PR