Answer the question
In order to leave comments, you need to log in
How to fix aiopg.sa error?
Hello! I'm studying the official tutorial on aiohttp, there was a problem at the stage of initializing the connection with postgresql,
conf = app['config']['postgres']
engine = await aiopg.sa.create_engine(
database=conf['database'],
user=conf['user'],
password=conf['password'],
host=conf['host'],
port=conf['port'],
minsize=conf['minsize'],
maxsize=conf['maxsize'],
)
app['db'] = engine
Traceback (most recent call last):
File "chapi_pools\main.py", line 14, in <module>
web.run_app(app)
File "C:\coding\Chapi\env\lib\site-packages\aiohttp\web.py", line 419, in run_app
loop.run_until_complete(_run_app(app,
File "c:\myprogramm\python\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\coding\Chapi\env\lib\site-packages\aiohttp\web.py", line 305, in _run_app
await runner.setup()
File "C:\coding\Chapi\env\lib\site-packages\aiohttp\web_runner.py", line 232, in setup
self._server = await self._make_server()
File "C:\coding\Chapi\env\lib\site-packages\aiohttp\web_runner.py", line 331, in _make_server
await self._app.startup()
File "C:\coding\Chapi\env\lib\site-packages\aiohttp\web_app.py", line 389, in startup
await self.on_startup.send(self)
File "C:\coding\Chapi\env\lib\site-packages\aiohttp\signals.py", line 34, in send
await receiver(*args, **kwargs) # type: ignore
File "C:\coding\Chapi\chapi_pools\db.py", line 46, in init_pg
engine = await aiopg.sa.create_engine(
File "C:\coding\Chapi\env\lib\site-packages\aiopg\sa\engine.py", line 69, in _create_engine
pool = await aiopg.create_pool(
File "C:\coding\Chapi\env\lib\site-packages\aiopg\pool.py", line 155, in from_pool_fill
await self._fill_free_pool(False)
File "C:\coding\Chapi\env\lib\site-packages\aiopg\pool.py", line 193, in _fill_free_pool
conn = await connect(
File "C:\coding\Chapi\env\lib\site-packages\aiopg\connection.py", line 38, in connect
coro = Connection(
File "C:\coding\Chapi\env\lib\site-packages\aiopg\connection.py", line 92, in __init__
self._loop.add_reader(self._fileno, self._ready, self._weakref)
File "c:\myprogramm\python\lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
Exception ignored in: <function Connection.__del__ at 0x04077268>
Traceback (most recent call last):
File "C:\coding\Chapi\env\lib\site-packages\aiopg\connection.py", line 512, in __del__
File "C:\coding\Chapi\env\lib\site-packages\aiopg\connection.py", line 310, in close
File "C:\coding\Chapi\env\lib\site-packages\aiopg\connection.py", line 285, in _close
File "c:\myprogramm\python\lib\asyncio\events.py", line 504, in remove_reader
NotImplementedError:
Answer the question
In order to leave comments, you need to log in
Also encountered this error.
Here is a similar question on stackoverflow .
There is a link to a solution there.
It helped me to put two lines in main.py:
# main.py
# ...
import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
app = web.Application()
app['config'] = config
# ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question