Skip to content

Commit 81852eb

Browse files
committed
doc: fix python example
Problem: A job submission Python example in the docs has an error, so it won't run, making it a poor example. It also prints the raw JobInfo object, which isn't very demonstrative. Update the example to fix the error and print something useful from the returned JobInfo result object.
1 parent abd95c1 commit 81852eb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

doc/python/job_submission.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,15 @@ as futures complete.
216216
result_fut.then(result_cb)
217217
218218
def result_cb(fut):
219-
print(fut.get_info())
219+
job = fut.get_info()
220+
result = job.result.lower()
221+
print(f"{job.id}: {result} with returncode {job.returncode}")
220222
221223
flux_handle = flux.Flux()
222224
jobspec = flux.job.JobspecV1.from_command(["/bin/true"])
223225
for _ in range(5):
224226
# submit 5 futures and attach callbacks to each one
225-
submit_future = flux.job.submit_async(f, jobspec)
227+
submit_future = flux.job.submit_async(flux_handle, jobspec)
226228
submit_future.then(submit_cb, flux_handle)
227229
# enter the flux event loop (the 'reactor') to trigger the callbacks
228230
# once the futures complete

0 commit comments

Comments
 (0)