3

I have a method in my python (2.7.6) code that I am looking to use multithreading subprocess on by following the advice given in another SO question

This is how the code is currently:

return self.capi(roi_rgb,"",False)

This is how I converted it:

pool = multiprocessing.Pool(None)
result = ""
r = pool.map_async(self.capi(roi_rgb,"",False), callback=result)
r.wait()
return result

but I'm getting errors with the above on the call to pool.map_async

TypeError: map_async() takes at least 3 arguments (3 given)
Community
  • 1
  • 1
Anthony
  • 33,838
  • 42
  • 169
  • 278
  • Please add the specific errors to your post. – ChrisP Apr 24 '16 at 02:45
  • @ChrisP `TypeError: map_async() takes at least 3 arguments (3 given)` – Anthony Apr 24 '16 at 02:53
  • Your call to `map_async` looks odd; does `self.capi` return a function? [The documentation](https://docs.python.org/3.5/library/multiprocessing.html#multiprocessing.pool.Pool.map_async) suggests the first argument is a function, followed by an iterable, and that `callback` should be a callable that accepts a single argument. – ChrisP Apr 24 '16 at 03:00

1 Answers1

0

According to https://docs.python.org/2/library/multiprocessing.html you need to give at least 2 positional arguments where as you gave it one positional and one keyword argument. (The third implicit arg is self)

So you need to pass the method a function and an iterable along with the callback.

P.s.that is a pretty useless error message isn't it?

karina
  • 805
  • 5
  • 10