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
import asyncio
import asyncpg
async def upload(data):
conn = await asyncpg.connect(database='t01')
async with conn.transaction():
await conn.executemany('insert into t (t) values ($1)', data)
loop = asyncio.get_event_loop()
data = ([v] for v in range(10))
loop.run_until_complete(upload(data))
If I change the data = ... line to
data = ([x] for v in range(10))
I am getting
...
File "asyncpg/protocol/protocol.pyx", line 354, in asyncpg.protocol.protocol.BaseProtocol._ensure_clear_state (asyncpg/protocol/protocol.c:59044)
asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progres
Keeping the erroneous data = ... line and after commenting out the async with conn.transaction() line, I am getting the following exception
File "asyncpg/protocol/protocol.pyx", line 181, in genexpr (asyncpg/protocol/protocol.c:55322)
File "test-script.py", line 11, in <genexpr>
data = ([x] for v in range(10))
NameError: name 'x' is not defined
When running within transaction, the exception should be exactly the same as running without a transaction - the exception shown on the last listing above.
The text was updated successfully, but these errors were encountered:
wrobell
changed the title
combination of executemany and transaction when an exception is raised
incorrect exception when using executemany within transaction
Mar 9, 2017
Please consider this script
If I change the
data = ...
line toI am getting
Keeping the erroneous
data = ...
line and after commenting out theasync with conn.transaction()
line, I am getting the following exceptionWhen running within transaction, the exception should be exactly the same as running without a transaction - the exception shown on the last listing above.
The text was updated successfully, but these errors were encountered: