Skip to content

No async version of .authenticate() #128

@joakimnordling

Description

@joakimnordling

It looks like there's no .authenticate_async(), just a normal .authenticate() method in the API client.

Thus, if you want to use the client in an async codebase, you should run the authentication code in a synchronous context and only after authenticating the client you should switch back to running async code (unless you can afford to get the event loop stuck for the duration of the authentication, which shouldn't happen frequently). This might be doable at least in some codebases, but makes the usage a bit more cumbersome than if there was an async function available for authenticating. What's worse is that the .call_async also might call the the non-async .authenticate() if you have not yet authenticated the client (solvable by authenticating beforehand) or if there's an error (didn't check deep enough to be 100% sure, but I think this is what happens if the authentication has expired, so this would be a bit harder to prevent). So there's async code that might reach out to the non-async version of .authenticate() that does network access.

Adding an async version of the .authenticate(), like .authenticate_async() should be somewhat simple to do and make it a lot easier to use the client in some cases and most importantly avoid accidentally getting the event loop stuck if there's a need to re-authenticate when making some call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions