# HG changeset patch # User Philippe Pepiot # Date 1585574363 -7200 # Node ID 39ee325e6758e55773c58c6018605f3d85bbf266 # Parent 3667f6df1ec34da236de55544bb2e1b959f6eb33 [server] avoid a possible race condition on _CnxSetPool.close() The pool could become empty between time to check and time to use. diff -r 3667f6df1ec3 -r 39ee325e6758 cubicweb/server/repository.py --- 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: