Ejemplo n.º 1
0
def run():
    global pool
    pool1 = JobPool(2)
    pool2 = JobPool()
    if pool1 != pool2:
        raise Exception("hmmm, I thought JobPool is 'Singleton'")
    try:
        JobPool(4)
    except Exception as e:
        print(("As expected, making a new JobPool with a"
               " different cpu count failed: %s") % e)

    pool = JobPool()
    jobs = []
    for j in range(1, 20):
        job = TestJob(str(j))
        jobs.append(job)
        pool.enqueue_job(job)

    sample_job = pool.get_asynch_result_object(jobs[3])

    # pool.terminate()

    pool.wait_for_all_jobs(ignore_error=True)

    # Test one of the jobs, to see if it is successful
    if sample_job.ready() and sample_job.successful():
        assert(jobs[3].result_set is True)
    else:
        assert(jobs[3].result_set is False)

    errors = pool.get_all_job_errors()
    # print("Following job errors were raised:", errors)

    try:
        pool.wait_for_all_jobs(ignore_error=False)
    except Exception as e:
        print("Seems we have some jobs that failed (expected): ", e)

    errs = [pool.get_job_error(job) for job in pool.get_failed_jobs()]

    # print(errs)

    assert len(errs) == len(errors), \
        "Number of errors from failed jobs: %d. Number of errors: %d" % \
        (len(errs), len(errors))
    assert False not in [x in errors for x in errs]

    # print [job.state for job in jobs]
    # print("Number of started jobs - number of printed results:", s)
    # print("Number of failed jobs:", len(errors))
    assert s == len(errors), \
        "Parallelization Error, what happened to the rest?"
Ejemplo n.º 2
0
def run():
    global pool
    pool1 = JobPool(2)
    pool2 = JobPool()
    if pool1 != pool2:
        raise Exception("hmmm, I thought JobPool is 'Singleton'")
    try:
        JobPool(4)
    except Exception as e:
        print(("As expected, making a new JobPool with a"
               " different cpu count failed: %s") % e)

    pool = JobPool()
    jobs = []
    for j in range(1, 20):
        job = TestJob(str(j))
        jobs.append(job)
        pool.enqueue_job(job)

    sample_job = pool.get_asynch_result_object(jobs[3])

    # pool.terminate()

    pool.wait_for_all_jobs(ignore_error=True)

    # Test one of the jobs, to see if it is successful
    if sample_job.ready() and sample_job.successful():
        assert (jobs[3].result_set is True)
    else:
        assert (jobs[3].result_set is False)

    errors = pool.get_all_job_errors()
    # print("Following job errors were raised:", errors)

    try:
        pool.wait_for_all_jobs(ignore_error=False)
    except Exception as e:
        print("Seems we have some jobs that failed (expected): ", e)

    errs = [pool.get_job_error(job) for job in pool.get_failed_jobs()]

    # print(errs)

    assert len(errs) == len(errors), \
        "Number of errors from failed jobs: %d. Number of errors: %d" % \
        (len(errs), len(errors))
    assert False not in [x in errors for x in errs]

    # print [job.state for job in jobs]
    # print("Number of started jobs - number of printed results:", s)
    # print("Number of failed jobs:", len(errors))
    assert s == len(errors), \
        "Parallelization Error, what happened to the rest?"
Ejemplo n.º 3
0
 global pool
 pool1 = JobPool(2)
 pool2 = JobPool()
 if pool1 != pool2:
     raise Exception("hmmm, I thought JobPool is 'Singleton'")
 try:
     pool3 = JobPool(4)
 except Exception as e:
     print "As expected, making a new JobPool with a different cpu count failed: %s" %e
     
 pool = JobPool()
 jobs = []
 for j in range(1,20):
     job = TestJob(str(j))
     jobs.append(job)                
     pool.enqueue_job(job)
 
 
 sample_job = pool.get_asynch_result_object(jobs[3])
 
 #pool.terminate()
 
 pool.wait_for_all_jobs(ignore_error=True)
 
 # Test one of the jobs, to see if it is successful
 if sample_job.ready() and sample_job.successful():
     assert jobs[3].result_set == True
 else:
     assert jobs[3].result_set == False
 
 errors = pool.get_all_job_errors()
Ejemplo n.º 4
0
    global pool
    pool1 = JobPool(2)
    pool2 = JobPool()
    if pool1 != pool2:
        raise Exception("hmmm, I thought JobPool is 'Singleton'")
    try:
        pool3 = JobPool(4)
    except Exception as e:
        print "As expected, making a new JobPool with a different cpu count failed: %s" % e

    pool = JobPool()
    jobs = []
    for j in range(1, 20):
        job = TestJob(str(j))
        jobs.append(job)
        pool.enqueue_job(job)

    sample_job = pool.get_asynch_result_object(jobs[3])

    #pool.terminate()

    pool.wait_for_all_jobs(ignore_error=True)

    # Test one of the jobs, to see if it is successful
    if sample_job.ready() and sample_job.successful():
        assert jobs[3].result_set == True
    else:
        assert jobs[3].result_set == False

    errors = pool.get_all_job_errors()
    print "Following job errors were raised:", errors