]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Use 'async with lock' instead of deprecated 'with await lock'
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 24 Mar 2020 07:51:52 +0000 (20:51 +1300)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 24 Mar 2020 08:05:54 +0000 (21:05 +1300)
psycopg3/connection.py
psycopg3/cursor.py

index 60516b69d124b85df097db4001684f5200f7ff28..cb56ed1ebef5fad1e8502191ac182279251b40bb 100644 (file)
@@ -209,7 +209,7 @@ class AsyncConnection(BaseConnection):
         await self._exec_commit_rollback(b"rollback")
 
     async def _exec_commit_rollback(self, command):
-        with await self.lock:
+        async with self.lock:
             status = self.pgconn.transaction_status
             if status == pq.TransactionStatus.IDLE:
                 return
index ae803327ddb2cf8421d79275c31ed8a150448763..667d9db7065d133d5f95771f0a29810ddf1f80b6 100644 (file)
@@ -104,7 +104,7 @@ class Cursor(BaseCursor):
 
 class AsyncCursor(BaseCursor):
     async def execute(self, query, vars=None):
-        with await self.conn.lock:
+        async with self.conn.lock:
             gen = self._execute_send(query, vars)
             results = await self.conn.wait(gen)
             self._execute_results(results)