示例#1
0
def test_plain_future():
    executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
    futures = FutureCollection()
    future = executor.submit(fib, 33)
    futures.add('fibonacci', future)
    assert futures.done('fibonacci') is False
    assert futures._state('fibonacci') is not None
    assert future in futures
    futures.pop('fibonacci')
    assert future not in futures
示例#2
0
def get_job_status(u):
    try:
        #_uuid_ = uuid.UUID(u)
        _uuid_ = u
        [futures, pid] = pid_dict[_uuid_]
        if futures.running():
            jd = json.dumps({"job_id": str(_uuid_), "status": "inprogress"})
            print(jd)
            return jd
        elif futures.done():
            jd = json.dumps({"job_id": str(_uuid_), "status": "completed"})
            print(jd)
            return jd
        else:
            jd = json.dumps({"job_id": str(_uuid_), "status": str(futures)})
            print(jd)
            return jd
    except KeyError:
        print('Key not found')
    except ValueError:
        print('UUID not found')