Commit 55bfa74f authored by Jérome Perrin's avatar Jérome Perrin

Change timeout handling code to wait while getting from the Queue

parent 5175c2dc
...@@ -25,6 +25,7 @@ import urllib ...@@ -25,6 +25,7 @@ import urllib
import xlrd import xlrd
import traceback import traceback
import multiprocessing import multiprocessing
import Queue
from dream.KnowledgeExtraction.DistributionFitting import DistFittest from dream.KnowledgeExtraction.DistributionFitting import DistFittest
from dream.KnowledgeExtraction.ImportExceldata import Import_Excel from dream.KnowledgeExtraction.ImportExceldata import Import_Excel
...@@ -105,13 +106,13 @@ def runWithTimeout(func, timeout, *args, **kw): ...@@ -105,13 +106,13 @@ def runWithTimeout(func, timeout, *args, **kw):
target=_runWithTimeout, target=_runWithTimeout,
args=(queue, func, args, kw)) args=(queue, func, args, kw))
process.start() process.start()
process.join(timeout) try:
if process.is_alive(): return queue.get(timeout=timeout)
# process still alive after timeout, terminate it except Queue.Empty:
process.terminate() process.terminate()
process.join()
raise TimeoutError() raise TimeoutError()
return queue.get() finally:
process.join()
def _runWithTimeout(queue, func, args, kw): def _runWithTimeout(queue, func, args, kw):
import signal import signal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment