From: Daniele Varrazzo Date: Thu, 26 Mar 2020 13:19:41 +0000 (+1300) Subject: Typoeoes X-Git-Tag: 3.0.dev0~671 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fae13de394d804bc7bd5f4d7d50b1652494b171;p=thirdparty%2Fpsycopg.git Typoeoes --- diff --git a/psycopg3/connection.py b/psycopg3/connection.py index cb56ed1eb..86ef56f0b 100644 --- a/psycopg3/connection.py +++ b/psycopg3/connection.py @@ -54,7 +54,7 @@ class BaseConnection: @classmethod def _connect_gen(cls, conninfo): """ - Generator to create a database connection using without blocking. + Generator to create a database connection without blocking. Yield pairs (fileno, `Wait`) whenever an operation would block. The generator can be restarted sending the appropriate `Ready` state when diff --git a/psycopg3/waiting.py b/psycopg3/waiting.py index 67f34bcb7..7a6580f68 100644 --- a/psycopg3/waiting.py +++ b/psycopg3/waiting.py @@ -61,35 +61,35 @@ async def wait_async(gen): Return what the generator eventually returned. """ - # Use a queue to block and restart after the fd state changes. + # Use an event to block and restart after the fd state changes. # Not sure this is the best implementation but it's a start. - e = Event() + ev = Event() loop = get_event_loop() ready = None def wakeup(state): nonlocal ready ready = state - e.set() + ev.set() try: while 1: fd, s = next(gen) - e.clear() + ev.clear() if s is Wait.R: loop.add_reader(fd, wakeup, Ready.R) - await e.wait() + await ev.wait() loop.remove_reader(fd) gen.send(ready) elif s is Wait.W: loop.add_writer(fd, wakeup, Ready.W) - await e.wait() + await ev.wait() loop.remove_writer(fd) gen.send(ready) elif s is Wait.RW: loop.add_reader(fd, wakeup, Ready.R) loop.add_writer(fd, wakeup, Ready.W) - await e.wait() + await ev.wait() loop.remove_reader(fd) loop.remove_writer(fd) gen.send(ready) diff --git a/tests/fix_db.py b/tests/fix_db.py index 140fa9d13..8487fedb8 100644 --- a/tests/fix_db.py +++ b/tests/fix_db.py @@ -100,7 +100,7 @@ def dsn(request): def pgconn(pq, dsn): """Return a PGconn connection open to `--test-dsn`.""" conn = pq.PGconn.connect(dsn.encode("utf8")) - if conn.status != 0: + if conn.status != pq.ConnStatus.OK: pytest.fail( f"bad connection: {conn.error_message.decode('utf8', 'replace')}" )