mirror of
https://github.com/python/cpython.git
synced 2025-11-08 05:39:34 +00:00
Fix two mp doc issues from #4012.
This commit is contained in:
parent
9290503b2a
commit
e3d70aed8e
1 changed files with 4 additions and 4 deletions
|
|
@ -232,7 +232,7 @@ For example::
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pool = Pool(processes=4) # start 4 worker processes
|
pool = Pool(processes=4) # start 4 worker processes
|
||||||
result = pool.applyAsync(f, [10]) # evaluate "f(10)" asynchronously
|
result = pool.apply_async(f, [10]) # evaluate "f(10)" asynchronously
|
||||||
print(result.get(timeout=1)) # prints "100" unless your computer is *very* slow
|
print(result.get(timeout=1)) # prints "100" unless your computer is *very* slow
|
||||||
print(pool.map(f, range(10))) # prints "[0, 1, 4,..., 81]"
|
print(pool.map(f, range(10))) # prints "[0, 1, 4,..., 81]"
|
||||||
|
|
||||||
|
|
@ -1505,7 +1505,7 @@ with the :class:`Pool` class.
|
||||||
The class of the result returned by :meth:`Pool.apply_async` and
|
The class of the result returned by :meth:`Pool.apply_async` and
|
||||||
:meth:`Pool.map_async`.
|
:meth:`Pool.map_async`.
|
||||||
|
|
||||||
.. method:: get([timeout)
|
.. method:: get([timeout])
|
||||||
|
|
||||||
Return the result when it arrives. If *timeout* is not ``None`` and the
|
Return the result when it arrives. If *timeout* is not ``None`` and the
|
||||||
result does not arrive within *timeout* seconds then
|
result does not arrive within *timeout* seconds then
|
||||||
|
|
@ -1535,7 +1535,7 @@ The following example demonstrates the use of a pool::
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pool = Pool(processes=4) # start 4 worker processes
|
pool = Pool(processes=4) # start 4 worker processes
|
||||||
|
|
||||||
result = pool.applyAsync(f, (10,)) # evaluate "f(10)" asynchronously
|
result = pool.apply_async(f, (10,)) # evaluate "f(10)" asynchronously
|
||||||
print(result.get(timeout=1)) # prints "100" unless your computer is *very* slow
|
print(result.get(timeout=1)) # prints "100" unless your computer is *very* slow
|
||||||
|
|
||||||
print(pool.map(f, range(10))) # prints "[0, 1, 4,..., 81]"
|
print(pool.map(f, range(10))) # prints "[0, 1, 4,..., 81]"
|
||||||
|
|
@ -1546,7 +1546,7 @@ The following example demonstrates the use of a pool::
|
||||||
print(it.next(timeout=1)) # prints "4" unless your computer is *very* slow
|
print(it.next(timeout=1)) # prints "4" unless your computer is *very* slow
|
||||||
|
|
||||||
import time
|
import time
|
||||||
result = pool.applyAsync(time.sleep, (10,))
|
result = pool.apply_async(time.sleep, (10,))
|
||||||
print(result.get(timeout=1)) # raises TimeoutError
|
print(result.get(timeout=1)) # raises TimeoutError
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue