We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c9a4d68 commit 9692e75Copy full SHA for 9692e75
src/asynchrony/various.py
@@ -1,4 +1,5 @@
1
import time
2
+import asyncio
3
4
5
async def retry_with_backoff(func, max_retries=3):
@@ -13,3 +14,17 @@ async def retry_with_backoff(func, max_retries=3):
13
14
if attempt < max_retries - 1:
15
time.sleep(0.0001 * attempt)
16
raise last_exception
17
+
18
19
+async def fetch_user(user_id: int) -> dict:
20
+ """Simulates fetching a user from a database"""
21
+ await asyncio.sleep(0.0001)
22
+ return {"id": user_id, "name": f"User{user_id}"}
23
24
25
+async def fetch_all_users(user_ids: list[int]) -> list[dict]:
26
+ users = []
27
+ for user_id in user_ids:
28
+ user = await fetch_user(user_id)
29
+ users.append(user)
30
+ return users
0 commit comments