Skip to content

Commit

Permalink
Merge pull request #7750 from DIRACGridBot/cherry-pick-2-0e77ca271-in…
Browse files Browse the repository at this point in the history
…tegration

[sweep:integration] fix (ProcessPool): add more safeguard when processing result queue
  • Loading branch information
fstagni authored Aug 13, 2024
2 parents 1cba046 + 8905772 commit fb144d9
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 fb144d9

Please sign in to comment.