Message371057
I was trying to use multiprocessing (via a concurrent.futures.ProcessPoolExecutor) and encountered an error when pickling a custom Exception. On closer examination I was able to create a simple test case that only involves pickle:
import pickle
class StrRegexError(Exception):
def __init__(self, *, pattern):
self.pattern = pattern
data = pickle.dumps(StrRegexError(pattern='test'))
instance = pickle.loads(data)
[pts/11@peru /srv/ansible]$ python3.8 ~/p.py
Traceback (most recent call last):
File "/home/badger/p.py", line 7, in <module>
instance = pickle.loads(data)
TypeError: __init__() missing 1 required keyword-only argument: 'pattern'
pickle can handle mandatory keyword args in other classes derived from object; it's only classes derived from Exception that have issues. |
|
Date |
User |
Action |
Args |
2020-06-08 23:46:10 | a.badger | set | recipients:
+ a.badger |
2020-06-08 23:46:10 | a.badger | set | messageid: <1591659970.45.0.239988250333.issue40917@roundup.psfhosted.org> |
2020-06-08 23:46:10 | a.badger | link | issue40917 messages |
2020-06-08 23:46:10 | a.badger | create | |
|