import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('funcx.sdk.asynchronous.polling_task').setLevel(logging.DEBUG)
This example creates an asynchronous FuncX Client and shows up to receive results
# Public tutorial endpoint: 4b116d3c-1703-4f8f-9f6f-39921e5864df
tutorial_endpoint = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
from funcx.sdk.client import FuncXClient
fxc = FuncXClient(funcx_service_address='http://localhost:5000/api/v1', asynchronous=True)
def sum1(nums):
import time
time.sleep(10)
return sum(nums)
func_id = fxc.register_function(sum1)
func_id
task = fxc.run([1, 2, 3, 45, 66], function_id=func_id, endpoint_id=tutorial_endpoint)
task
import asyncio
await task
print(task.result())
def boom(l):
return l/0
func_id2 = fxc.register_function(boom)
func_id2
task2 = fxc.run([1, 2, 3, 45, 66], function_id=func_id2, endpoint_id=tutorial_endpoint)
await task2
print(task2.result())