postgresql - Ignore/reconnect for closed connection in pool -


i have problem pool.acquire() , closed connection in pool. setting on pg server set connection timeout 120 second. when use pool.acquire() raise error because connection closed:

sleep 150 traceback (most recent call last):   file "test.py", line 21, in <module>     loop.run_until_complete(test_select())   file "/usr/local/cellar/python3/3.5.1/frameworks/python.framework/versions/3.5/lib/python3.5/asyncio/base_events.py", line 337, in run_until_complete     return future.result()   file "/usr/local/cellar/python3/3.5.1/frameworks/python.framework/versions/3.5/lib/python3.5/asyncio/futures.py", line 274, in result     raise self._exception   file "/usr/local/cellar/python3/3.5.1/frameworks/python.framework/versions/3.5/lib/python3.5/asyncio/tasks.py", line 239, in _step     result = coro.send(none)   file "test.py", line 10, in test_select async pool.acquire() conn:   file "/usr/local/lib/python3.5/site-packages/aiopg/utils.py", line 116, in __aenter__     self._conn = yield self._coro   file "/usr/local/lib/python3.5/site-packages/aiopg/pool.py", line 170, in _acquire     assert not conn.closed, conn assertionerror: <aiopg.connection.connection object @ 0x106f7df98> 

and code

import asyncio import aiopg  dsn = 'dbname=dbname user=user password=password host=127.0.0.1' async def test_select():     async aiopg.create_pool(dsn) pool:         print("sleep 150")         await asyncio.sleep(150)         async pool.acquire() conn:             async conn.cursor() cur:                 await cur.execute("select 1")                 ret = []                 async row in cur:                     ret.append(row)                 assert ret == [(1,)]     print("all done")   loop = asyncio.get_event_loop() loop.run_until_complete(test_select()) 

how solve problem. thanks!


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -