aio-libs / aio-libs/aiopg

Should aiopg work correctly with connection_factory parameter?

Đang mở
#287 13 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
1.4k
Fork
170
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi!

I want to use logical replication that's why I want to use connection_factory=LogicalReplicationConnection (`from psycopg2.extras import LogicalReplicationConnection`). I tried to debug app and I saw that psycopg2.connect initialized fine but code from method Connection._ready raised exception.

Without this parameter app works fine. Is it a bug?

Python 3.5.2
PostgreSQL (9.5.4)
Fedora release 24 (Twenty Four)

```
async def go():
async with aiopg.create_pool(dsn, connection_factory=LogicalReplicationConnection) as pool:
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 1")
async for row in cur:
print(row)
```

```
Traceback (most recent call last):
File "1.py", line 27, in
loop.run_until_complete(go())
File "/usr/lib64/python3.5/asyncio/base_events.py", line 387, in run_until_complete
return future.result()
File "/usr/lib64/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib64/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "1.py", line 16, in go
async with aiopg.create_pool(dsn, connection_factory=LogicalReplicationConnection) as pool:
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/utils.py", line 77, in __aenter__
self._obj = yield from self._coro
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/pool.py", line 46, in _create_pool
yield from pool._fill_free_pool(False)
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/pool.py", line 203, in _fill_free_pool
**self._conn_kwargs)
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/utils.py", line 67, in __iter__
resp = yield from self._coro
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/connection.py", line 83, in _connect
oids = yield from _enable_hstore(conn)
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/connection.py", line 39, in _enable_hstore
""")
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/cursor.py", line 113, in execute
yield from self._conn._poll(waiter, timeout)
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/connection.py", line 237, in _poll
yield from asyncio.wait_for(self._waiter, timeout, loop=self._loop)
File "/usr/lib64/python3.5/asyncio/tasks.py", line 392, in wait_for
return fut.result()
File "/usr/lib64/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/home/budulianin/Documents/projects/pypgbus/pypgbus_venv/lib64/python3.5/site-packages/aiopg/connection.py", line 134, in _ready
state = self._conn.poll()
psycopg2.ProgrammingError: syntax error

Unclosed connection
connection:
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.