24

There is frighteningly little strict API documentation (read: ZERO) for multiprocessing.pool.ApplyResult. The multiprocessing explanation doc talks about ApplyResults, but does not define them.

The same appears to apply to multiprocessing.pool.Pool, although the Python multiprocessing guide appears to cover it better.

Even the ApplyResult help() results are paltry:

 |  get(self, timeout=None)
 |  
 |  ready(self)
 |  
 |  successful(self)
 |  
 |  wait(self, timeout=None)
  • Get() and Ready() I get. Those are fine.

  • I have absolutely no idea what wait() is for, given that you are dealing with a "pool", which one would assume would waits for you in the get() call. Is this "wait for the result, but don't get it now" Or is it an OS-style wait? And if so, what would that even mean?

  • I am equally unsure of what successful() is all about.

2 Answers 2

22

You're right that there is in a glitch in the documentation: the class is actually documented as AsyncResult, not ApplyResult. The two are different names for the same class:

>>> multiprocessing.pool.ApplyResult is multiprocessing.pool.AsyncResult
True

The name may have been changed at some point and the docs weren't consistently updated, but everything is documented, it's just documented under the wrong name. (There is a closed bug in which someone pointed out that the docs mention AsyncResult but the class is actually called ApplyResult, so they added AsyncResult as an alias.)

1
0

This is what I see from the code:

  • ready(): returns true if the task run by the "thread" is ready to return a result
  • get(timeout=None): waits for a result for timeout units (in floating-point seconds) and returns the result on a successful completion. On timeout raises a TimeoutError, on a non-successful completion raises the associated exception.
  • wait(timeout=None): waits on a condition variable set by the worker "thread", as per threading.Condition.wait([timeout]) DOES NOT IMPLY reaping of the child "thread".
  • successful(): if ready, returns True if the result of get() will be a value. Otherwise, returns False (i.e. the result will be an exception). If assertions are enabled, will raise ValueError if the result is not ready.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.