[PATCH 05 of 23 cubicweb V2] [database/pool/misc] rename variable to better match reality

Laurent Peuch cortex at worlddomination.be
Fri Jan 17 14:37:02 CET 2020


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1576830483 -3600
#      Fri Dec 20 09:28:03 2019 +0100
# Node ID 5568552e2e190db9121e08e9a7c15f384b290972
# Parent  891f688858cef7cff9c02389b29c2a2539007e00
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r 5568552e2e19
[database/pool/misc] rename variable to better match reality

diff --git a/cubicweb/server/repository.py b/cubicweb/server/repository.py
--- a/cubicweb/server/repository.py
+++ b/cubicweb/server/repository.py
@@ -187,10 +187,10 @@ class LifoDeque(queue.LifoQueue):
 
 class _CnxSetPool:
 
-    def __init__(self, source, size, min_size=3, min_timeout=0.1, max_timeout=5,
+    def __init__(self, source, max_size, min_size=3, min_timeout=0.1, max_timeout=5,
                  low_load_delay=30, close_delay=5):
         self._cnxsets = []
-        self.size = size
+        self.max_size = max_size
         self.min_size = min_size
         self.current_size = None
         self.min_timeout = min_timeout
@@ -202,11 +202,11 @@ class _CnxSetPool:
         self._last_time_we_waited = None
         self._last_time_connection_close = None
 
-        if self.size is not None:
+        if self.max_size is not None:
             self._queue = LifoDeque()
 
-            if self.min_size > self.size:
-                self.min_size = max(1, int(self.size / 3))
+            if self.min_size > self.max_size:
+                self.min_size = max(1, int(self.max_size / 3))
 
             self.current_size = FastReadCounter(value=self.min_size)
 
@@ -238,12 +238,12 @@ class _CnxSetPool:
             except queue.Empty:
                 pass  # probably for some race condition we missed it
 
-        if self.current_size.value < self.size:
+        if self.current_size.value < self.max_size:
             try:
                 return self._queue.get(block=True, timeout=self.min_timeout)
             except queue.Empty:
                 # size could have increased during waiting
-                if self.current_size.value < self.size:
+                if self.current_size.value < self.max_size:
                     # we have load, open another connection
                     cnxset = self.source.wrapped_connection()
                     self._cnxsets.append(cnxset)



More information about the cubicweb-devel mailing list