-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to enable / disable async to new_client_from_env() #84
Comments
There is another reason why this change is beneficial: type checking. Currently, a type checker can't know what kind of client is being returned from the |
Hi, @mjpieters! Thank you for raising this 👍. |
I had already created a PR for this but neglected to reference this issue in the PR. So, if you want, the todo item on your list can be marked as 'done' if you choose to merge that PR! 😄 |
That's great! I'll take a look 👍 |
Summary
Allow the program to decide on async vs sync client use when loading the credentials from the environment.
Use cases
Whether or not an async client is needed is a choice for the specific application code, not the environment. Please allow me to load an async client in an async codebase, and a sync client in a sync codebase:
Proposed solution
Add a new
is_async
keyword argument tonew_client_from_env()
, defaulting toNone
. If it is left to the default, the environment variable is used, otherwise the value is passed on directly tonew_client()
:(I made the test for
ENV_IS_ASYNC_CLIENT
a little broader to also acceptT
,true
,1
, etc, as signalling 'true')Is there a workaround to accomplish this today?
I have to options right now:
ENV_IS_ASYNC_CLIENT
environment variable manually before callingnew_client_from_environment()
. This feels very, very janky. I should not have to manipulate the environment variables visible to a 3rd-party SDK to switch between async modes for my code base.new_client()
directly but then miss out on the helpful validation thatnew_client_from_environment()
also provides.The text was updated successfully, but these errors were encountered: