]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor: set the meaningful timeout for _try_cancel() as a default 780/head
authorDenis Laxalde <denis.laxalde@dalibo.com>
Tue, 16 Apr 2024 07:11:30 +0000 (09:11 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 17 Apr 2024 21:51:20 +0000 (23:51 +0200)
psycopg/psycopg/_copy.py
psycopg/psycopg/_copy_async.py
psycopg/psycopg/connection.py
psycopg/psycopg/connection_async.py
psycopg/psycopg/cursor.py
psycopg/psycopg/cursor_async.py

index d4db84a2d94fc1155d3c84bf3cf88d78841b5fcd..2b0e77ca7e0887a39d42a75d8c686414cb81c652 100644 (file)
@@ -160,7 +160,7 @@ class Copy(BaseCopy["Connection[Any]"]):
             # (which might or might not have been already transferred entirely to
             # the client, so we won't necessary see the exception associated with
             # canceling).
-            self.connection._try_cancel(timeout=5.0)
+            self.connection._try_cancel()
             self.connection.wait(self._end_copy_out_gen())
 
 
index a371f185dc1eae44f7c12c091ac36c78db24b8ca..c94f05db920ffeeef12c2982b5e3556e34d07427 100644 (file)
@@ -159,7 +159,7 @@ class AsyncCopy(BaseCopy["AsyncConnection[Any]"]):
             # (which might or might not have been already transferred entirely to
             # the client, so we won't necessary see the exception associated with
             # canceling).
-            await self.connection._try_cancel(timeout=5.0)
+            await self.connection._try_cancel()
             await self.connection.wait(self._end_copy_out_gen())
 
 
index ad233c3754f866812a884f658052a09838b2bca9..c2be01560e2d456d01d8c214ddb8da1343003e2a 100644 (file)
@@ -288,7 +288,7 @@ class Connection(BaseConnection[Row]):
         else:
             self.cancel()
 
-    def _try_cancel(self, *, timeout: float = 30.0) -> None:
+    def _try_cancel(self, *, timeout: float = 5.0) -> None:
         try:
             self.cancel_safe(timeout=timeout)
         except Exception as ex:
index 78501852271a8aa53e2d422f53e75ab0e1549aa4..b0c8b753e2076f124a7230604ee72ac1b3ea382e 100644 (file)
@@ -308,7 +308,7 @@ class AsyncConnection(BaseConnection[Row]):
             else:
                 self.cancel()
 
-    async def _try_cancel(self, *, timeout: float = 30.0) -> None:
+    async def _try_cancel(self, *, timeout: float = 5.0) -> None:
         try:
             await self.cancel_safe(timeout=timeout)
         except Exception as ex:
index b49c3e5afdbe4527ba18d3b58248613963e06d28..42d5d8e453b2055f2283c6dd056befeb59035d41 100644 (file)
@@ -159,7 +159,7 @@ class Cursor(BaseCursor["Connection[Any]", Row]):
                 if self._pgconn.transaction_status == ACTIVE:
                     # Try to cancel the query, then consume the results
                     # already received.
-                    self._conn._try_cancel(timeout=5.0)
+                    self._conn._try_cancel()
                     try:
                         while self._conn.wait(self._stream_fetchone_gen(first=False)):
                             pass
index 46700da526c6f37db66fdd62442d4bad92be65f5..37a0d255f92cb81336c284b4773f42029e0a6774 100644 (file)
@@ -164,7 +164,7 @@ class AsyncCursor(BaseCursor["AsyncConnection[Any]", Row]):
                 if self._pgconn.transaction_status == ACTIVE:
                     # Try to cancel the query, then consume the results
                     # already received.
-                    await self._conn._try_cancel(timeout=5.0)
+                    await self._conn._try_cancel()
                     try:
                         while await self._conn.wait(
                             self._stream_fetchone_gen(first=False)