Closed willgdjones closed 7 years ago
Yes.
>>> import pathos
>>> p = pathos.pools.ProcessPool()
>>> f = lambda x:x*x
>>> res = p.amap(f, range(3))
>>> res.get(timeout=1)
[0, 1, 4]
>>> p.close()
>>> p.join()
Thanks for the quick reply @mmckerns ! One other thing, is it possible to specify a callback once a worker has completed a given job - e.g. to update a progress bar?
you should be able to make a progress bar by using res = Pool().imap(...)
or uimap
. They produce res
as an iterator, and you can then iterate over res
getting one result at a time as they come in. There is a good example of this I posted on SO, but I couldn't find the url for it quickly unfortunately.
Thanks @mmckerns! Pool or ProcessPool?
Oh, right... it should be ProcessPool
above.
Hi @mmckerns, the timeout keyword in res.get()
seems to timeout the entire pool. Is there a good way to timeout an individual worker and let the pool keep going?
@ortiz1093: Maybe this is not what you want to hear, but I think you'd want to use individual async pipes instead of a pool.
@mmckerns, no worries. I appreciate the response. I'm pretty new to multiprocessing, so I really didn't know what to use. I'll look into the async pipes. Thanks!
Hi there - is there some support for Pathos to timeout workers after e.g. 30 seconds?
Thanks!