From: Daniele Varrazzo Date: Tue, 19 Sep 2023 20:38:03 +0000 (+0200) Subject: perf(windows): don't use wait_c. X-Git-Tag: pool-3.1.8~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca41e834ec3aee184a297646776dbf093adaffdf;p=thirdparty%2Fpsycopg.git perf(windows): don't use wait_c. The function was reported to use excessive CPU. Need to investigate, however, for the moment, suspend its usage on Windows. See #645. --- diff --git a/docs/news.rst b/docs/news.rst index 63290f460..978cf3860 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -17,6 +17,7 @@ Psycopg 3.1.11 (unreleased) usage (:ticket:`#628`). - Fix integer overflow in C/binary extension with OID > 2^31 (:ticket:`#630`). - Fix loading of intervals with days and months or years (:ticket:`#643`). +- Work around excessive CPU usage on Windows (reported in :ticket:`#645`). - Fix building on Solaris and derivatives (:ticket:`#632`). - Fix possible lack of critical section guard in async `~AsyncCursor.executemany()`. diff --git a/psycopg/psycopg/waiting.py b/psycopg/psycopg/waiting.py index 2c4a10fd1..80827152c 100644 --- a/psycopg/psycopg/waiting.py +++ b/psycopg/psycopg/waiting.py @@ -10,6 +10,7 @@ These functions are designed to consume the generators returned by the import os +import sys import select import selectors from typing import Dict, Optional @@ -310,7 +311,10 @@ if "PSYCOPG_WAIT_FUNC" in os.environ: ) wait = globals()[fname] -elif _psycopg: +# On Windows, for the moment, avoid using wait_c, because it was reported to +# use excessive CPU (see #645). +# TODO: investigate why. +elif _psycopg and sys.platform != "win32": wait = wait_c elif selectors.DefaultSelector is getattr(selectors, "SelectSelector", None):