batch_res = fxc.batch_run(batch)

    for item in batch_res:
        poll_queue.put(item)

success_count = 0
fail_count = 0
print(f"Moving to status checks...")
while True:
    tids_to_check = []
    poll_batch = []
    while len(tids_to_check) < fx_batch_size and not poll_queue.empty():
        tid = poll_queue.get()
        tids_to_check.append(tid)

    x = fxc.get_batch_result(tids_to_check)

    for tid_key in x:
        if not x[tid_key]['pending']:
            if x[tid_key]['status'] != 'failed':
                success_count += 1
            else:
                print("FAILED!")
                fail_count += 1
                print(x[tid_key]['exception'])
                # x[tid_key]['exception'].reraise()

        else:
            poll_queue.put(tid_key)
    print(f"Success Count: {success_count}")
    print(f"Fail Count: {fail_count}")
Example #2
0
    # #     with open(item, 'r') as f:
    # #         f.close()
    #
    # time.sleep(sleep_s)
    return "hello, world!"


# func_id = fxc.register_function(function=sleep_func, function_name='hpdc_sleep_extractor')
container_uuid = fxc.register_container('/home/tskluzac/xtract-matio.img', 'singularity')
print("Container UUID: {}".format(container_uuid))
func_id = fxc.register_function(matio_extract,
                                #ep_id, # TODO: We do not need ep id here
                                container_uuid=container_uuid,
                                description="New sum function defined without")

for fx_id in id_list:

    for i in range(1,10):
        task_id = fxc.run({'event'}, endpoint_id=fx_id, function_id=func_id)

    while True:

        result = fxc.get_batch_result([task_id])
        print(result)

        for tid in result:
            if result[tid]['status'] == 'failed':
                exc = result[tid]['exception']
                exc.reraise()
        time.sleep(2)