コード例 #1
0
ファイル: knot_identification.py プロジェクト: amoliu/lfd
def dt_code_to_knot(dt_code):
    def dt_code_to_knot_wrapper(q, x):
        result = _dt_code_to_knot(x)
        q.put(result)
        q.close()

    q = multiprocessing.Queue(1)
    proc = multiprocessing.Process(target=dt_code_to_knot_wrapper, args=(q, dt_code))
    proc.start()
    TIMEOUT = 1
    try:
        result = q.get(True, TIMEOUT)
    except:
        LOG.warn("Timeout for knot identification exceeded, assuming no knot")
        result = None
    finally:
        proc.terminate()
    return result
コード例 #2
0
ファイル: knot_identification.py プロジェクト: zzz622848/lfd
def dt_code_to_knot(dt_code):
    def dt_code_to_knot_wrapper(q, x):
        result = _dt_code_to_knot(x)
        q.put(result)
        q.close()

    q = multiprocessing.Queue(1)
    proc = multiprocessing.Process(target=dt_code_to_knot_wrapper,
                                   args=(q, dt_code))
    proc.start()
    TIMEOUT = 1
    try:
        result = q.get(True, TIMEOUT)
    except:
        LOG.warn("Timeout for knot identification exceeded, assuming no knot")
        result = None
    finally:
        proc.terminate()
    return result