Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add call information to client.asyncresult.AsyncResult #2456

tbekolay opened this Issue · 3 comments

2 participants


I was writing some analysis code that spawned a bunch of asynchronous figure creation jobs. I wanted to look at the results of each job afterwards, but I wasn't able to find anything in AsyncResult that has information about the actual call that was made.

I created a few little helper functions that got me what I wanted, to give you an idea of how the functionality was helpful. lview is a LoadBalancedView and results is a list to keep track of all the AsyncResults.

def schedule(lview, results, func, *args, **kwargs):
    res = lview.apply(func, *args, **kwargs)
    res.call_str = "%s(%s, %s)" % (
        ', '.join(map(str, args)),
        ', '.join(["%s=%s" % (key, val) for key, val in kwargs.items()]))

def print_outputs(results):
    for res in results:
        print ("--------------------------------------"
        print res.call_str
        print res.display_outputs()

Then, I would scheduled all my jobs in a big main script; e.g.,

schedule(lview, r, plot_trajectory, f1path, name='f1')
schedule(lview, r, plot_trajectory, f2path, name='f2')
schedule(lview, r, plot_trajectory, f3path, name='f3')

Then at the end of my script I wait for all of the results and look through them.

for res in r:

# How many were successful?
good = []
bad = []
for res in r:
    if res.successful():
print "%d figure jobs finished successfully, %d failed." % (
    len(good), len(bad))

if bad:
    print "Printing first failure:"
    print ("--------------------------------------"
    print bad[0].display_outputs()
    print bad[0].result()
    print "Figures created!"

So yeah, if I didn't have to write the schedule function that would be great! :)


It would have to be a little bit careful, since some args may have enormous representations which should be truncated, but this is a good idea.


It could be part of the .metadata, a separate entry for the function name and for the args... maybe the truncated repr could be like what shows up in %whos?

@minrk minrk removed the type-enhancement label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.