]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Add an assertion in wait_selector() / wait_epoll()
authorDenis Laxalde <denis@laxalde.org>
Sun, 17 Oct 2021 19:02:41 +0000 (21:02 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 16 Nov 2021 10:28:18 +0000 (11:28 +0100)
Making sure the ready event matches what we're waiting on.

psycopg/psycopg/waiting.py

index 59bbd6559bc409fdd1aa2332f08492fc582cf7da..b75dbe5b598de93a14a22c18bc82435d9fae2746 100644 (file)
@@ -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)