Commit 1b37dd9e authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

[server] extract creating a new cnxset in a _new_cnxset() helper

So we can move logic specific to _CnxSetPool here.
parent 6ae8de571145
......@@ -157,6 +157,9 @@ class _BaseCnxSet:
return None
def get(self):
return self._new_cnxset()
def _new_cnxset(self):
return self._source.wrapped_connection()
def release(self, cnxset):
......@@ -181,9 +184,12 @@ class _CnxSetPool(_BaseCnxSet):
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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment