]> git.ipfire.org Git - thirdparty/psycopg.git/commit
refactor: check for closed connection in wait functions
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 7 Oct 2025 23:49:52 +0000 (01:49 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 13 Oct 2025 01:25:16 +0000 (03:25 +0200)
commit64eb36ebe472562ab1a7ec73a61e1a6d02b21462
tree1f173c5cf225873406840759af3907638beb2072
parentc02bad23ced12dbe1a7819a0607b5acab48e1af4
refactor: check for closed connection in wait functions

Catch and display errors in a more homogeneous way: if a wait function
finds a connection closed it will raise an OperationalError chained to
the OSError obtained from stat'ing the socket. Previously control would
have gone back to the generator with a read-ready state and it would
have failed on whatever libpq function would have touched the socket.

Fix the problem reported in #608 affecting the epoll wait function, for
which we opted to use the poll function instead (which, more simply,
made the closed fd easier to spot).

note that on Windows it's not possible to use os.fstat() to ckeck a
socket state, therefore make it no-op.
psycopg/psycopg/waiting.py
psycopg_c/psycopg_c/_psycopg/waiting.pyx
tests/test_waiting.py
tests/test_waiting_async.py