tasks = [ pool.fetchrow("SELECT * FROM users WHERE id = $1", 1), pool.fetchrow("SELECT * FROM users WHERE id = $1", 2), pool.fetchrow("SELECT * FROM users WHERE id = $1", 3), ] result = await asyncio.gather(*tasks) print(result)
[get_rows(request.state.pgpool, number) for number in range(0, 100)] return await asyncio.gather(*tasks, return_exceptions=False) async def get_rows(conn, num: int): """औಘ""" print(“ͪΐͬͱͬͯͶ {num=}") result = await conn.fetchrow("SELECT * FROM users WHERE id = $1", num) print(“ܾ·ͬͨʂ”) return result
- Oreilly & Associates Inc 謝辞 •Yury Selivanov - Asyncio in Python 3 7 and 3 8 https://www.youtube.com/watch?v=ReXxO_azV-w •asyncioͷTaskʹؔ͢Δجૅࣝ https://aish.dev/python/20200711_asyncio_task.html •To many many internet articles, great books and member. 🙏