[server] extract creating a new cnxset in a _new_cnxset() helper
So we can move logic specific to _CnxSetPool here.
--- a/cubicweb/server/repository.py Mon Mar 30 15:19:23 2020 +0200
+++ b/cubicweb/server/repository.py Mon Mar 30 15:23:56 2020 +0200
@@ -152,6 +152,9 @@
return None
def get(self):
+ return self._new_cnxset()
+
+ def _new_cnxset(self):
return self._source.wrapped_connection()
def release(self, cnxset):
@@ -173,9 +176,12 @@
self._queue = queue.Queue()
for i in range(size):
- cnxset = source.wrapped_connection()
- self._cnxsets.append(cnxset)
- self._queue.put_nowait(cnxset)
+ self._queue.put_nowait(self._new_cnxset())
+
+ def _new_cnxset(self):
+ cnxset = super()._new_cnxset()
+ self._cnxsets.append(cnxset)
+ return cnxset
def qsize(self):
return self._queue.qsize()