You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -316,6 +316,54 @@ When consuming methods from the API clients, the requests could fail for a numbe
316
316
resets is exposed in the ``reset_at``property. When the header is unset, this value will be ``-1``.
317
317
- Network timeouts: Adjustable by passing a ``timeout`` argument to the client. See the `rate limit docs <https://auth0.com/docs/policies/rate-limits>`__ for details.
318
318
319
+
=========================
320
+
Asynchronous Environments
321
+
=========================
322
+
323
+
This SDK provides async methods built on top of `asyncio <https://docs.python.org/3/library/asyncio.html>`__. To make them available you must have Python >=3.6and the `aiohttp <https://docs.aiohttp.org/en/stable/>`__ module installed.
324
+
325
+
Then additional methods with the ``_async`` suffix will be added to modules created by the ``management.Auth0``classor to classes that are passed to the ``asyncify`` method. For example:
326
+
327
+
.. code-block:: python
328
+
329
+
import asyncio
330
+
import aiohttp
331
+
from auth0.v3.asyncify import asyncify
332
+
from auth0.v3.management import Auth0, Users, Connections
333
+
from auth0.v3.authentication import Users as AuthUsers
334
+
335
+
auth0= Auth0('domain', 'mgmt_api_token')
336
+
337
+
asyncdef main():
338
+
# users = auth0.users.all() <= sync
339
+
users=await auth0.users.all_async() # <= async
340
+
341
+
# To share a session amongst multiple calls to the same service
342
+
asyncwith auth0.users as users:
343
+
data=await users.get_async(id)
344
+
users.update_async(id, data)
345
+
346
+
# Use asyncify directly on services
347
+
Users= asyncify(Users)
348
+
Connections= asyncify(Connections)
349
+
users= Users(domain, mgmt_api_token)
350
+
connections= Connections(domain, mgmt_api_token)
351
+
352
+
# Create a session and share it among the services
0 commit comments