aioodbc Pool is incompatible with Python 3.10+
thomasleveil opened this issue · 1 comments
thomasleveil commented
Python 3.10 changed the signature of the asyncio.Condition()
class :
Changed in version 3.10: Removed the loop parameter.
The current aioodbc.Pool
constructor uses the old signature which raises the TypeError: Condition.__init__() got an unexpected keyword argument 'loop'
error.
How to reproduce
With Python 3.10 or 3.11, run the following code
import asyncio
import aioodbc
loop = asyncio.get_event_loop()
async def example_pool():
dsn = 'Driver=SQLite;Database=sqlite.db'
pool = await aioodbc.create_pool(dsn=dsn, loop=loop)
async with pool.acquire() as conn:
cur = await conn.cursor()
await cur.execute("SELECT 42;")
r = await cur.fetchall()
print(r)
await cur.close()
await conn.close()
pool.close()
await pool.wait_closed()
if __name__ == '__main__':
loop.run_until_complete(example_pool())
Actual result
tmp.py:5: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
Traceback (most recent call last):
File "tmp.py", line 23, in <module>
loop.run_until_complete(example_pool())
File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 650, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "tmp.py", line 10, in example_pool
pool = await aioodbc.create_pool(dsn=dsn, loop=loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\Lib\site-packages\aioodbc\pool.py", line 25, in _create_pool
pool = Pool(minsize=minsize, maxsize=maxsize, echo=echo, loop=loop,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\Lib\site-packages\aioodbc\pool.py", line 47, in __init__
self._cond = asyncio.Condition(loop=loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Condition.__init__() got an unexpected keyword argument 'loop'
Process finished with exit code 1
Expected result
no error
jettify commented
Fixed in master.