Skip to content

Commit

Permalink
Merge pull request #7738 from chaen/v8.0_fix_processPoolEmpty
Browse files Browse the repository at this point in the history
fix (ProcessPool): add more safeguard when processing result queue
  • Loading branch information
fstagni committed Aug 13, 2024
2 parents 28570bc + 8990149 commit 0e77ca2
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 0e77ca2

Please sign in to comment.