From: Daniele Varrazzo Date: Sat, 19 Aug 2023 17:23:38 +0000 (+0100) Subject: fix: add missing lock in async executemany with no pipeline X-Git-Tag: pool-3.1.8~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c0972957bb3886cd0ab249e81064c44011f1ca3;p=thirdparty%2Fpsycopg.git fix: add missing lock in async executemany with no pipeline --- diff --git a/docs/news.rst b/docs/news.rst index 5b7a07f52..bc770323a 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -14,6 +14,8 @@ Psycopg 3.1.11 (unreleased) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Fix integer overflow in C/binary extension with OID > 2^31 (:ticket:`#630`). +- Fix possible lack of critical section guard in async + `~AsyncCursor.executemany()`. Current release diff --git a/psycopg/psycopg/cursor_async.py b/psycopg/psycopg/cursor_async.py index ab7b07348..78acf409e 100644 --- a/psycopg/psycopg/cursor_async.py +++ b/psycopg/psycopg/cursor_async.py @@ -118,9 +118,10 @@ class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]): self._executemany_gen_pipeline(query, params_seq, returning) ) else: - await self._conn.wait( - self._executemany_gen_no_pipeline(query, params_seq, returning) - ) + async with self._conn.lock: + await self._conn.wait( + self._executemany_gen_no_pipeline(query, params_seq, returning) + ) except e._NO_TRACEBACK as ex: raise ex.with_traceback(None)