[PATCH 4 of 9 cubicweb] [server] use a LifoQueue in _CnxSetPool

Philippe Pepiot ph at itsalwaysdns.eu
Tue Mar 31 18:28:59 CEST 2020


# HG changeset patch
# User Philippe Pepiot <ph at itsalwaysdns.eu>
# Date 1585575002 -7200
#      Mon Mar 30 15:30:02 2020 +0200
# Node ID f08a3c909bfaaef5c07376ffc23d35987a33b5c3
# Parent  0dca6687fcf5fd2754da447856360c365d8d15c2
# Available At https://philpep.org/pub/hg/cubicweb
#              hg pull https://philpep.org/pub/hg/cubicweb -r f08a3c909bfa
[server] use a LifoQueue in _CnxSetPool

In postgresql, some cache is attached to the connection. Using a LifoQueue
(last-in, first-out) makes a few connections to get the most load which give
best performance.

diff --git a/cubicweb/server/repository.py b/cubicweb/server/repository.py
--- a/cubicweb/server/repository.py
+++ b/cubicweb/server/repository.py
@@ -173,7 +173,7 @@ class _CnxSetPool(_BaseCnxSet):
     def __init__(self, source, size):
         super().__init__(source)
         self._cnxsets = []
-        self._queue = queue.Queue()
+        self._queue = queue.LifoQueue()
 
         for i in range(size):
             self._queue.put_nowait(self._new_cnxset())



More information about the cubicweb-devel mailing list