Skip to content

Bad poll state while using async connection with PGDATESTYLE set to sql,mdy #115

@nobleread

Description

@nobleread

While asynchronously connecting to database, exception that indicates wrong poll state is thrown.

PGDATESTYLE env variable is set to "sql, mdy" which is correct value according to postgres documentation (8.5.2 of https://www.postgresql.org/docs/9.5/datatype-datetime.html).
It seems like this is the source of the problem. When PGDATESTYLE is set to "iso, mdy" psycopg2cffi works correctly.

test.py tries to connect (async) to database and execute "SELECT 1" on it.

[root@host121 pgtest]# (export PGDATESTYLE='iso, mdy';  pypy3 test.py )
start
wait connect
wait select
[(1,)]

[root@host121 pgtest]# (export PGDATESTYLE='sql, mdy';  pypy3 test.py )
start
wait connect
bad state from poll: 3

The exception throw is:

<class 'psycopg2cffi._impl.exceptions.OperationalError'>
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    wait_select(aconn)
  File "/usr/local/pypy3/site-packages/psycopg2cffi-2.8.1-py3.6-linux-x86_64.egg/psycopg2cffi/extras.py", line 607, in wait_select
    raise conn.OperationalError("bad state from poll: %s" % state)
psycopg2cffi._impl.exceptions.OperationalError: bad state from poll: 3

While using normal psycopg2 implementation connection works as expected.

Let me know if I can provide more details.

MR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions