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

Closing connection object throws exception #65

Closed
sumerc opened this issue Jul 10, 2015 · 8 comments
Closed

Closing connection object throws exception #65

sumerc opened this issue Jul 10, 2015 · 8 comments
Assignees

Comments

@sumerc
Copy link

sumerc commented Jul 10, 2015

Hi,

I am using aiopg with a Pool object that is shared among coroutines. Every once in a while, randomly I see following error:

psycopg2.ProgrammingError: close cannot be used while an asynchronous query is u
nderway

I can reproduce the issue with following:


pool = yield from aiopg.create_pool(dsn)
with (yield from pool.cursor(timeout=1.0)) as cur:
    yield from cur.execute("SELECT pg_sleep(2)")

It seems valid to raise TimeoutError rather than ProgrammingError, I believe. What do you think?

Thanks,

@asvetlov
Copy link
Member

Got it.

@asvetlov asvetlov self-assigned this Jul 14, 2015
@kashifrazzaqui
Copy link

We are also facing this issue, can you please patch this. We don't specify a timeout value though.

Specifically for us it occurs when we pass a 'sub-query' to cursor.execute

@asvetlov
Copy link
Member

What do you mean by sub-query?
cusor object is intended to execute only one query in the same time.

@kashifrazzaqui
Copy link

@bitdancer
Copy link
Contributor

Changing this from a ProgrammingError to a TimeoutError seems to have been done in 8ca948e, which also makes sure the connection and cursor are closed when it happens. Can this issue be closed?

@asvetlov
Copy link
Member

Not yet. I should fix closing cursor with pending query first.
Will do it next week -- just after making new aiohttp release.

@sumerc
Copy link
Author

sumerc commented Nov 10, 2015

Do we have any estimate for the fix? If sub-query is hard to implement, I think we should include the initial problem as soonn as possible. Because currently this blocks one from implementing a retry policy on specific DB errors. e.g: retry query on TimeOut Error 2 times.

@asvetlov
Copy link
Member

Fixed, d0e5f86 has explicit test for the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants