From: Daniele Varrazzo Date: Fri, 5 Sep 2025 23:57:52 +0000 (+0200) Subject: refactor: auto-generate sync pipeline object from async one X-Git-Tag: 3.2.10~5^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d12c61d10f7ac15b3eeeb3f246b244ee87a4499;p=thirdparty%2Fpsycopg.git refactor: auto-generate sync pipeline object from async one --- diff --git a/psycopg/psycopg/_pipeline.py b/psycopg/psycopg/_pipeline.py index a32064af7..1276f434a 100644 --- a/psycopg/psycopg/_pipeline.py +++ b/psycopg/psycopg/_pipeline.py @@ -1,5 +1,8 @@ +# WARNING: this file is auto-generated by 'async_to_sync.py' +# from the original file '_pipeline_async.py' +# DO NOT CHANGE! Change the original file instead. """ -commands pipeline management +Psycopg Pipeline object implementation. """ # Copyright (C) 2021 The Psycopg Team @@ -21,7 +24,7 @@ logger = logging.getLogger("psycopg") class Pipeline(BasePipeline): - """Handler for connection in pipeline mode.""" + """Handler for (sync) connection in pipeline mode.""" __module__ = "psycopg" _conn: Connection[Any] diff --git a/psycopg/psycopg/_pipeline_async.py b/psycopg/psycopg/_pipeline_async.py index dd4deca65..058526071 100644 --- a/psycopg/psycopg/_pipeline_async.py +++ b/psycopg/psycopg/_pipeline_async.py @@ -1,5 +1,5 @@ """ -commands pipeline management +Psycopg AsyncPipeline object implementation. """ # Copyright (C) 2021 The Psycopg Team @@ -21,7 +21,7 @@ logger = logging.getLogger("psycopg") class AsyncPipeline(BasePipeline): - """Handler for async connection in pipeline mode.""" + """Handler for (async) connection in pipeline mode.""" __module__ = "psycopg" _conn: AsyncConnection[Any] @@ -30,6 +30,9 @@ class AsyncPipeline(BasePipeline): super().__init__(conn) async def sync(self) -> None: + """Sync the pipeline, send any pending command and receive and process + all available results. + """ try: async with self._conn.lock: await self._conn.wait(self._sync_gen()) diff --git a/tools/async_to_sync.py b/tools/async_to_sync.py index d0895d9c4..08e6627f9 100755 --- a/tools/async_to_sync.py +++ b/tools/async_to_sync.py @@ -34,6 +34,7 @@ ALL_INPUTS = """ psycopg/psycopg/_copy_async.py psycopg/psycopg/connection_async.py psycopg/psycopg/cursor_async.py + psycopg/psycopg/_pipeline_async.py psycopg/psycopg/_server_cursor_async.py psycopg_pool/psycopg_pool/null_pool_async.py psycopg_pool/psycopg_pool/pool_async.py