For some reason, running your example runs into a NotImplementedError of asyncio when it tries to create a connection pool. The PostgreSQL psycopg2 package works just fine when I use it directly without aiopg.
To Reproduce
As already said, the code is just the first example of the README with the dsn modified to connect to my database.
import asyncio
import aiopg
dsn = ...
async def go():
async with aiopg.create_pool(dsn) as pool:
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 1")
ret = []
async for row in cur:
ret.append(row)
assert ret == [(1,)]
loop = asyncio.get_event_loop()
loop.run_until_complete(go())
Running the example with psycopg2 works just fine.
Traceback (most recent call last):
File "C:\Users\mtroester\source\repos\kfz_webapi_migration\aiopg_test.py", line 22, in <module>
loop.run_until_complete(go())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\mtroester\source\repos\kfz_webapi_migration\aiopg_test.py", line 12, in go
async with aiopg.create_pool(dsn) as pool:
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\utils.py", line 82, in __aenter__
self._obj = await self._coro
^^^^^^^^^^^^^^^^
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\pool.py", line 300, in from_pool_fill
await self._fill_free_pool(False)
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\pool.py", line 336, in _fill_free_pool
conn = await connect(
^^^^^^^^
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\connection.py", line 65, in connect
connection = Connection(
^^^^^^^^^^^
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\connection.py", line 772, in __init__
self._loop.add_reader(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\events.py", line 534, in add_reader
raise NotImplementedError
NotImplementedError
Exception ignored in: <function Connection.__del__ at 0x0000015325BEA0C0>
Traceback (most recent call last):
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\connection.py", line 1188, in __del__
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\connection.py", line 995, in close
File "C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\aiopg\connection.py", line 977, in _close
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\asyncio\events.py", line 537, in remove_reader
NotImplementedError:
Python Version
$ python --version
Python 3.11.9
(it's the official Python 3.11 version installed by the Windows 11 App Store)
aiopg Version
$ python -m pip show aiopg
Name: aiopg
Version: 1.4.0
Summary: Postgres integration with asyncio.
Home-page: https://aiopg.readthedocs.io
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: BSD
Location: C:\Users\mtroester\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages
Requires: async-timeout, psycopg2-binary
Required-by:
OS
Windows 11 Pro
Version 23H2
Additional context
I'm not sure whether I'm using the correct package versions together. When your base example doesn't work anymore, that's a huge deal IMO.
Code of Conduct
[X] I agree to follow the aio-libs Code of Conduct
Describe the bug
For some reason, running your example runs into a NotImplementedError of asyncio when it tries to create a connection pool. The PostgreSQL psycopg2 package works just fine when I use it directly without aiopg.
To Reproduce
As already said, the code is just the first example of the README with the dsn modified to connect to my database.
Running the example with psycopg2 works just fine.
I've tried both Python 3.11 and 3.12, but still same error. I even downgraded to Python 3.11 as I've seen you don't support 3.12 yet.
python -m pip list
for my 3.11 environment yieldsExpected behavior
Same result as in the example. Assertion passes.
Logs/tracebacks
Python Version
aiopg Version
OS
Windows 11 Pro Version 23H2
Additional context
I'm not sure whether I'm using the correct package versions together. When your base example doesn't work anymore, that's a huge deal IMO.
Code of Conduct