From: Alexkane (@Alexkane) <noreply+Alexkane@github.com>
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Subject: Re: [psycopg/psycopg] PR #1469: perf: don't wait on the event loop when the socket is writable
Date: Fri, 06 Nov 2026 02:48:49 +0000
Message-ID: <gh-psycopg-psycopg-1469-rc4488505198@github.com> (raw)
In-Reply-To: <gh-psycopg-psycopg-1469-rc4437757827@github.com>
References: <gh-psycopg-psycopg-1469@github.com>
<gh-psycopg-psycopg-1469-rc4437757827@github.com>
(on psycopg/psycopg/waiting.py)
Good catch, thanks. Added `MAX_SKIPPED_WAITS = 100` and the `sleep(0)` as you suggested. Measured here with a ticker task alongside an `executemany()` of 50k rows: the ticker's longest wait goes from 339 ms to 1 ms, the executemany from 0.34 to 0.38 s (1.65 s before the PR), and a `cancel()` now lands in ~270 ms, most of it the pipeline draining on exit (1.4 s before the PR). Note the counter is per `wait_async()` call, so a `copy()` doing one write per call is not covered by it; that is the same as Linux before the PR, where those writes didn't block either. Happy to make it a module-level counter if you'd rather cover that too.