Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is documentation for multiprocessing.pool.ApplyResult?

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.

like image 208
Mark Gerolimatos Avatar asked Nov 23 '16 20:11

Mark Gerolimatos


People also ask

What is a multiprocessing pool?

Functional Programming in Python In this lesson, you'll dive deeper into how you can use multiprocessing. Pool . It creates multiple Python processes in the background and spreads out your computations for you across multiple CPU cores so that they all happen in parallel without you needing to do anything.

What is Python multiprocessing pool?

The multiprocessing. pool. Pool in Python provides a pool of reusable processes for executing ad hoc tasks. A process pool can be configured when it is created, which will prepare the child workers. A process pool object which controls a pool of worker processes to which jobs can be submitted.

What is multiprocessing Freeze_support?

multiprocessing. freeze_support() This function will allow a frozen program to create and start new processes via the multiprocessing. Process class when the program is frozen for distribution on Windows. If the function is called and the program is not frozen for distribution, then it has no effect.

How does pool Apply_async work?

The apply_async() function can be called directly to execute a target function in the process pool. The call will not block, but will instead immediately return an AsyncResult object that we can ignore if our function does not return a value.


1 Answers

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.)

like image 192
BrenBarn Avatar answered Oct 04 '22 00:10

BrenBarn