[server] avoid a possible race condition on _CnxSetPool.close()
The pool could become empty between time to check and time to use.
--- a/cubicweb/server/repository.py Mon Mar 30 15:17:10 2020 +0200
+++ b/cubicweb/server/repository.py Mon Mar 30 15:19:23 2020 +0200
@@ -198,9 +198,11 @@
yield cnxset
def close(self):
- while not self._queue.empty():
- cnxset = self._queue.get_nowait()
-
+ while True:
+ try:
+ cnxset = self._queue.get_nowait()
+ except queue.Empty:
+ break
try:
cnxset.close(True)
except Exception as e: