From: Daniele Varrazzo Date: Sat, 19 Feb 2022 17:19:31 +0000 (+0100) Subject: refactor(pool): update some debug logging X-Git-Tag: pool-3.1.1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0e6601da09a67523869796f4a1d83f464736d9c;p=thirdparty%2Fpsycopg.git refactor(pool): update some debug logging 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). --- diff --git a/psycopg_pool/psycopg_pool/pool.py b/psycopg_pool/psycopg_pool/pool.py index 20ba8c109..9eb052e4c 100644 --- a/psycopg_pool/psycopg_pool/pool.py +++ b/psycopg_pool/psycopg_pool/pool.py @@ -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) diff --git a/psycopg_pool/psycopg_pool/pool_async.py b/psycopg_pool/psycopg_pool/pool_async.py index ce26b2cf2..864a50019 100644 --- a/psycopg_pool/psycopg_pool/pool_async.py +++ b/psycopg_pool/psycopg_pool/pool_async.py @@ -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)