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.1.18~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d230d4000940f98c0faf73978d17f9f2862cc95;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 c5a6a7608..f511a39d3 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -7,6 +7,15 @@ ``psycopg`` release notes ========================= +Future releases +--------------- + +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 7064f6038..6b09c69f0 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