Skip to content

Commit

Permalink
fix (ProcessPool): add more safeguard when processing result queue
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Jul 26, 2024
1 parent 1b904ba commit 8990149
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/DIRAC/Core/Utilities/ProcessPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
executing same type of callables in subprocesses and hence you are expecting the same type of results
everywhere.
"""

import errno
import inspect
import multiprocessing
Expand Down Expand Up @@ -911,8 +912,14 @@ def processResults(self):
if processed == 0:
log.debug("Process results, but queue is empty...")
break
# get task
task = self.__resultsQueue.get()
# In principle, there should be a task right away. However,
# queue.empty can't be trusted (https://docs.python.org/3/library/queue.html#queue.Queue.empty)
try:
task = self.__resultsQueue.get(timeout=10)
except queue.Empty:
log.warn("Queue.empty lied to us again...")
return 0

log.debug("__resultsQueue.get", f"t={time.time() - start:.2f}")
# execute callbacks
try:
Expand Down

0 comments on commit 8990149

Please sign in to comment.