From: Denis Laxalde Date: Sun, 17 Oct 2021 19:02:41 +0000 (+0200) Subject: Add an assertion in wait_selector() / wait_epoll() X-Git-Tag: 3.0.5~10^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb38222e1341b6b27f60cb19230c56547e681257;p=thirdparty%2Fpsycopg.git Add an assertion in wait_selector() / wait_epoll() Making sure the ready event matches what we're waiting on. --- diff --git a/psycopg/psycopg/waiting.py b/psycopg/psycopg/waiting.py index 59bbd6559..b75dbe5b5 100644 --- a/psycopg/psycopg/waiting.py +++ b/psycopg/psycopg/waiting.py @@ -59,6 +59,7 @@ def wait_selector( sel.unregister(fileno) # note: this line should require a cast, but mypy doesn't complain ready: Ready = rlist[0][1] + assert s & ready s = gen.send(ready) except StopIteration as ex: @@ -237,6 +238,7 @@ def wait_epoll( ready = Ready.R if ev & ~select.EPOLLIN: ready |= Ready.W + assert s & ready s = gen.send(ready) evmask = poll_evmasks[s] epoll.modify(fileno, evmask)