Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play nice with multiprocessing? #147

Open
dylancaponi opened this issue Oct 1, 2018 · 4 comments
Open

Play nice with multiprocessing? #147

dylancaponi opened this issue Oct 1, 2018 · 4 comments

Comments

@dylancaponi
Copy link

How does one make this library play nice with multiprocessing?

@retry(wait=wait_fixed(1), stop=stop_after_attempt(1))
def test_mp(foo):
    print(foo)
    raise Exception

entries = [1, 2, 3, 4, 5]
p = Pool(4)
p.map(test_mp, entries)

Output:

1
2
3
4
5
Traceback (most recent call last):
  File "tenacity_test.py", line 28, in <module>
    p.map(test_mp, entries)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 644, in get
    raise self._value
multiprocessing.pool.MaybeEncodingError: Error sending result: '<multiprocessing.pool.ExceptionWithTraceback object at 0x10e17c860>'. Reason: 'TypeError("can't pickle _thread.RLock objects",)'
@ajcann
Copy link

ajcann commented Jan 14, 2021

This still appears to be an issue. Anything I can do to help? Perhaps related to - https://stackoverflow.com/questions/44144584/typeerror-cant-pickle-thread-lock-objects

@kevlubkcm
Copy link

i believe this also causes issues with cloudpickle and thus joblib

import tenacity
import cloudpickle

@tenacity.retry
def f(x):
    return x

cloudpickle.dumps(f)
TypeError: cannot pickle '_thread._local' object

@aforadi
Copy link

aforadi commented Feb 21, 2022

Facing the same issue.

sergei-maertens added a commit to open-formulieren/open-forms that referenced this issue Apr 8, 2024
The retry error from tenacity uses threading locks under the hood,
which cannot be pickled. Specifying reraise=True avoids this
particular codepath.

See upstream issues:

* jd/tenacity#429
* jd/tenacity#182
* jd/tenacity#147
@shoang22
Copy link

Any update on this? Facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants