-
Notifications
You must be signed in to change notification settings - Fork 162
Description
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.
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.
import psycopg2
dsn = ...
conn = psycopg2.connect(dsn=dsn)
cursor = conn.cursor()
cursor.execute("SELECT 1")
rows = cursor.fetchall() # contains [(1,)] as expected
cursor.close()
conn.close()
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 yields
Package Version
---------------- -----------
aiofiles 24.1.0
aiohappyeyeballs 2.4.0
aiohttp 3.10.5
aiopg 1.4.0
aiosignal 1.3.1
async-timeout 4.0.3
attrs 24.2.0
colorama 0.4.6
frozenlist 1.4.1
idna 3.7
multidict 6.0.5
numpy 1.26.4
pandas 2.2.0
pip 24.2
psycopg2-binary 2.9.9
python-dateutil 2.9.0.post0
pytz 2024.1
six 1.16.0
tqdm 4.66.2
tzdata 2024.1
yarl 1.9.4
Expected behavior
Same result as in the example. Assertion passes.
Logs/tracebacks
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: [email protected]
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
- I agree to follow the aio-libs Code of Conduct