From: Daniele Varrazzo Date: Fri, 26 Jan 2024 00:29:29 +0000 (+0000) Subject: fix: force a sync exiting the pipeline mode X-Git-Tag: 3.2.0~94^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fde1a0d9241c50890bf4d8ac0fc6c33a8348b310;p=thirdparty%2Fpsycopg.git fix: force a sync exiting the pipeline mode Without it there may be a deadlock and we would be waiting to fetch a result that will never come. Close #685. --- diff --git a/docs/news.rst b/docs/news.rst index 3be638ed4..3c8a2e1d3 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -30,6 +30,12 @@ Psycopg 3.2 (unreleased) .. __: https://numpy.org/doc/stable/reference/arrays.scalars.html#built-in-scalar-types +Psycopg 3.1.18 (unreleased) +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Fix possible deadlock on pipeline exit (:ticket:`685`). + + Current release --------------- diff --git a/psycopg/psycopg/_pipeline.py b/psycopg/psycopg/_pipeline.py index 909310eba..05d0beb64 100644 --- a/psycopg/psycopg/_pipeline.py +++ b/psycopg/psycopg/_pipeline.py @@ -132,8 +132,7 @@ class BasePipeline: self._enqueue_sync() yield from self._communicate_gen() finally: - # No need to force flush since we emitted a sync just before. - yield from self._fetch_gen(flush=False) + yield from self._fetch_gen(flush=True) def _communicate_gen(self) -> PQGen[None]: """Communicate with pipeline to send commands and possibly fetch