supertokens-python icon indicating copy to clipboard operation
supertokens-python copied to clipboard

Support asynchronous origin function

Open aprilis opened this issue 1 year ago • 1 comments

We want to use origin function in InputAppInfo as described in https://supertokens.com/docs/emailpassword/common-customizations/multiple-clients.

Our logic is to download current origin list from our database using Django ORM. However, currently this is not possible because of the exception: django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async

Wrapping the ORM part with sync_to_async will make the whole function asynchronous but then it must be handled correctly by supertokens (using await keyword). The only solution is to update this repo to handle asynchronous origin function.

aprilis avatar May 23 '24 09:05 aprilis

hey @aprilis this is a good suggestion. In the meantime though, you can load up the list of origins from the database / refresh them in the background periodically and then read from the in memory list.

rishabhpoddar avatar May 23 '24 10:05 rishabhpoddar