Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect exception when using executemany within transaction #85

Closed
wrobell opened this issue Mar 9, 2017 · 0 comments
Closed

incorrect exception when using executemany within transaction #85

wrobell opened this issue Mar 9, 2017 · 0 comments
Assignees
Labels

Comments

@wrobell
Copy link

wrobell commented Mar 9, 2017

Please consider this script

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.

@wrobell wrobell changed the title combination of executemany and transaction when an exception is raised incorrect exception when using executemany within transaction Mar 9, 2017
@elprans elprans added the bug label Mar 14, 2017
@elprans elprans self-assigned this Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants