]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor(pool): update some debug logging
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 19 Feb 2022 17:19:31 +0000 (18:19 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 19 Feb 2022 17:22:32 +0000 (18:22 +0100)
Drop debug logging on `MaintenanceTask.init()`, which is not
particularly useful. Add debug entries on tasks `run()` early bailout,
which is a more interesting condition to follow (and would have allowed
to spot #230 more easily).

psycopg_pool/psycopg_pool/pool.py
psycopg_pool/psycopg_pool/pool_async.py

index 20ba8c109d8cb90147adabc73c01206a0ac238ca..9eb052e4cd0dbfbfd4f420987017bce3e0163dd7 100644 (file)
@@ -740,7 +740,6 @@ class MaintenanceTask(ABC):
 
     def __init__(self, pool: "ConnectionPool"):
         self.pool = ref(pool)
-        logger.debug("task created in %s: %s", threading.current_thread().name, self)
 
     def __repr__(self) -> str:
         pool = self.pool()
@@ -756,6 +755,7 @@ class MaintenanceTask(ABC):
         pool = self.pool()
         if not pool or pool.closed:
             # Pool is no more working. Quietly discard the operation.
+            logger.debug("task run discarded: %s", self)
             return
 
         logger.debug("task running in %s: %s", threading.current_thread().name, self)
@@ -770,6 +770,7 @@ class MaintenanceTask(ABC):
         pool = self.pool()
         if not pool or pool.closed:
             # Pool is no more working. Quietly discard the operation.
+            logger.debug("task tick discarded: %s", self)
             return
 
         pool.run_task(self)
index ce26b2cf2741bf233ab496d6808cfd2d10c6943d..864a50019cf32ae8c383a8e9a21deba1f4f97b0f 100644 (file)
@@ -658,6 +658,7 @@ class MaintenanceTask(ABC):
         pool = self.pool()
         if not pool or pool.closed:
             # Pool is no more working. Quietly discard the operation.
+            logger.debug("task run discarded: %s", self)
             return
 
         await self._run(pool)
@@ -671,6 +672,7 @@ class MaintenanceTask(ABC):
         pool = self.pool()
         if not pool or pool.closed:
             # Pool is no more working. Quietly discard the operation.
+            logger.debug("task tick discarded: %s", self)
             return
 
         pool.run_task(self)