Hello folks! I'm using the `concurrent.futures.ProcessPoolExecutor` with a
couple of functions that have been decorated with a class decorator. Both
`concurrent.futures` and `multiprocessing` breaks because "the object's
can't be pickled". There's a really simple fix for this, which is just,
instead of "decorating" the function (with the @), instantiate the
decorator and use it directly.
Example. This is my (very simple, for demonstration purposes) decorator:
class CheckOnlyIntegers:
def __init__(self, fn):
self.fn = fn
def __call__(self, *args):
if not all([type(arg) == int for arg in args]):
raise ValueError("Invalid param is not an integer")
return self.fn(*args)
If I define a simple `add` function and decorate it using the
`CheckOnlyIntegers` decorator:
@CheckOnlyIntegers
def add(x, y):
return x + y
and try using a regular `ProcessPoolExecutor().submit(add, 2, 3)`, it fails
with:
```
Can't pickle