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

'Unexpectedly, there's no async cursor here' #887

Closed
PCaff opened this Issue Apr 5, 2019 · 9 comments

Comments

Projects
None yet
2 participants
@PCaff
Copy link

PCaff commented Apr 5, 2019

Started getting this error this week. Nothing has changed in my processes. I could not longer pull this package as python3 -m pip install pyscopg2, had to change to python3 -m pip install pyscopg2-binary.

Can anyone explain why this would happen? I set my connection as async_=True, but now all of a sudden that config is not passed to the cursor.

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Apr 5, 2019

It's something that changed with psycopg 2.8. Do you have a way to reproduce?

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Apr 5, 2019

If there is a bug I suggest to go back to psycopg 2.7.7 but I would like to investigate as you shouldn't see this message.

@PCaff

This comment has been minimized.

Copy link
Author

PCaff commented Apr 5, 2019

I'm sure a simple test of an async process would produce this. I'm going to try to do this now.

@PCaff

This comment has been minimized.

Copy link
Author

PCaff commented Apr 5, 2019

Looks like you cannot pull a cursor out:

import psycopg2
connection = psycopg2.connect(dbname=db, host=host, port='5439', user=user, password=passw, async_=True)
cursor = connection.cursor()

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
psycopg2.OperationalError: asynchronous connection attempt underway
@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Apr 5, 2019

You have to complete connection before using cursors.

>>> import psycopg2
>>> from psycopg2.extras import wait_select
>>> cnn = psycopg2.connect('', async_=True)
>>> wait_select(cnn)
>>> cur = cnn.cursor()
@PCaff

This comment has been minimized.

Copy link
Author

PCaff commented Apr 5, 2019

Oh wow, didn't have to do that in 2.7. Is this new functionality? @dvarrazzo

@PCaff

This comment has been minimized.

Copy link
Author

PCaff commented Apr 5, 2019

@dvarrazzo
So, after a

wait_select(connection)

the error is reproduced by

connection.poll()

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Apr 5, 2019

Oh wow, didn't have to do that in 2.7. Is this new functionality? @dvarrazzo

No, it's no new functionality: it's as it always worked.

@dvarrazzo

This comment has been minimized.

Copy link
Member

dvarrazzo commented Apr 5, 2019

I see, will try to push a fix soon as I'm sure it will affect many people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.