import asyncio
import aiopg
async def main():
async with aiopg.create_pool("DSN string") as pg_pool:
await asyncio.gather(*[do_something(pg_pool) for i in range(10)])
async def do_something(pg_pool):
async with pg_pool.acquire() as connection:
async with connection.cursor() as cursor:
transaction = await cursor.begin() # object MagicMock can't be used in 'await' expression
try:
await cursor.execute("...", [])
await transaction.commit()
except Exception as e:
await transaction.rollback()
if __name__ == '__main__':
asyncio.run(main())
Hi everyone,
Could u help me to mock aiopg's connection pool? I have error
object MagicMock can't be used in 'await' expression
Best regards, Alex