question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi,

we’ve integrated Auth0 in a FastAPI application and at the moment, we’re forced to run the requests to Auth0 in a thread pool since the Auth0 library uses requests that is IO blocking.

Is there any plan to support AsyncIO?

Running each request in a thread pool is resource-intensive and does not allow us to leverage the non-blocking IO towards Auth0 APIs. In the long term, this will not be maintainable/scalable in our view.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ca-simone-chiorazzocommented, Apr 4, 2022

Hi @adamjmcgrath,

thanks for the update! I’ll try to test it this week, I’ll keep you posted on this.

Best regards, Simone

1reaction
adamjmcgrathcommented, Apr 5, 2022

Hi @ca-simone-chiorazzo (and others who have supported this issue @chiora93 @MwinyiMoha @Giaco9 @krissetto @willianantunes @bradydean)

We have a branch that currently supports asyncio for the ~Management client~ (Edit: supports the Management and Authentication clients) (requires python >=3.6 and aiohttp), you can test it out by installing the branch using pip (see https://pip.pypa.io/en/stable/topics/vcs-support/#supported-vcs), eg

pip install git+https://github.com/auth0/auth0-python.git@asyncio aiohttp

Then:

import asyncio
from auth0.v3.management import Auth0

domain = 'myaccount.auth0.com'
mgmt_api_token = 'MGMT_API_TOKEN'

auth0 = Auth0(domain, mgmt_api_token)

async def main():
  # u = auth0.users.all() <= sync
  u = await auth0.users.all_async() # <= async

asyncio.run(main())

We would be grateful if you try it out that you let us know how you got on with it

Read more comments on GitHub >

github_iconTop Results From Across the Web

asyncio — Asynchronous I/O — Python 3.11.1 documentation
Hello World!: asyncio is a library to write concurrent code using the async/await syntax. asyncio is used as a foundation for multiple Python...
Read more >
Async IO in Python: A Complete Walkthrough
Async IO is a concurrent programming design that has received dedicated support in Python, evolving rapidly from Python 3.4 through 3.7, and probably...
Read more >
Asyncio support — python-can 4.0.0 documentation
This library supports receiving messages asynchronously in an event loop using the can.Notifier class. There will still be one thread per CAN bus...
Read more >
Python Asyncio: The Complete Guide
It is proposed to make coroutines a proper standalone concept in Python, and introduce new supporting syntax. The ultimate goal is to help ......
Read more >
An introduction to asynchronous programming in Python with ...
Python 3 has a native support for async programming, Async IO, which provides a simple way to execute concurrent tasks. First, let's set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found