aio-libs / aiopg

aiopg is a library for accessing a PostgreSQL database from the asyncio
http://aiopg.readthedocs.io
BSD 2-Clause "Simplified" License
1.39k stars 159 forks source link

Suppress "Future exception was never retrieved" #862

Closed Pliner closed 3 years ago

Pliner commented 3 years ago

The fix suppresses the following error via ugly hack using .add_done_callback(lambda f: f.exception()):

Future exception was never retrieved
future: <Future finished exception=OperationalError('Connection closed')>

Also I had to add loop.is_closed() to suppress this error in tests:

Traceback (most recent call last):
  File "/Users/yurypliner/Sources/aiopg/aiopg/pool.py", line 476, in __del__
    conn.close()
  File "/Users/yurypliner/Sources/aiopg/aiopg/connection.py", line 995, in close
    self._close()
  File "/Users/yurypliner/Sources/aiopg/aiopg/connection.py", line 990, in _close
    self._notifies_proxy.close(
  File "/Users/yurypliner/Sources/aiopg/aiopg/utils.py", line 152, in close
    self._close_event.set_exception(exception)
  File "/Users/yurypliner/.pyenv/versions/3.9.2/lib/python3.9/asyncio/base_events.py", line 746, in call_soon
    self._check_closed()
  File "/Users/yurypliner/.pyenv/versions/3.9.2/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
codecov[bot] commented 3 years ago

Codecov Report

Merging #862 (6814434) into master (6f9958b) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #862   +/-   ##
=======================================
  Coverage   93.42%   93.43%           
=======================================
  Files          11       11           
  Lines        1566     1568    +2     
  Branches      184      186    +2     
=======================================
+ Hits         1463     1465    +2     
  Misses         72       72           
  Partials       31       31           
Impacted Files Coverage Δ
aiopg/connection.py 95.84% <100.00%> (+<0.01%) :arrow_up:
aiopg/utils.py 91.42% <100.00%> (+0.08%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6f9958b...6814434. Read the comment docs.