Postgresql 忽略/重新连接池中已关闭的连接

Postgresql 忽略/重新连接池中已关闭的连接,postgresql,python-3.x,python-asyncio,Postgresql,Python 3.x,Python Asyncio,我对pool.acquire()和池中的关闭连接有一些问题。 PG服务器上的设置将连接超时设置为120秒。当我使用pool.acquire()时,由于连接已关闭,这是一个raise错误: Sleep 150 Traceback (most recent call last): File "test.py", line 21, in <module> loop.run_until_complete(test_select()) File "/usr/local/Cell

我对pool.acquire()和池中的关闭连接有一些问题。 PG服务器上的设置将连接超时设置为120秒。当我使用pool.acquire()时,由于连接已关闭,这是一个raise错误:

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 with pool.acquire() as conn:
  File "/usr/local/lib/python3.5/site-packages/aiopg/utils.py", line 116, in __aenter__
    self._conn = yield from 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 at 0x106f7df98>
如何解决这个问题。 谢谢

解决方案之一