import modal
remote_fn = modal.Function.lookup(<namespace>, <fn_name>)
fn_call = remote_fn.spawn(job_id)
unique_job_id = fn_call.object_id # store this in db
import modal
pending_job_ids = [] # fetch from db
for call_id in pending_job_ids:
function_call = modal.functions.FunctionCall.from_id(call_id)
try:
result = function_call.get(timeout=0)
print(f"job {call_id} completed with result {result}")
except TimeoutError:
print(f"job {call_id} still pending")
except Exception as e:
print(f"job {call_id} failed with exception {e}")