Unlike other libpq functions, PQflush() doesn't have a guard for invalid
connections and will segfault if the connection gets closed.
Also check the return value of the PQflush calls: as we are not using
the wrapped version pgconn.flush(), the function doesn't automatically
throw an exception on failure.
)
def flush(self) -> int:
+ # PQflush segfaults if it receives a NULL connection
if not self._pgconn_ptr:
raise e.OperationalError("flushing failed: the connection is closed")
rv: int = impl.PQflush(self._pgconn_ptr)
cdef int cires
while True:
- if libpq.PQflush(pgconn_ptr) == 0:
+ if pgconn.flush() == 0:
break
status = yield WAIT_RW
if ready & Ready.W:
- libpq.PQflush(pgconn_ptr)
+ pgconn.flush()
if not commands:
break
commands.popleft()()