Code example for: "Can't pickle local object 'DeepDiff.__init__.<locals>.<lambda>'"
behrm opened this issue · comments
Bernhard Ehrminger commented
hi Sep,
here is some Code to reproduce the problem:
from concurrent.futures.process import ProcessPoolExecutor
from concurrent.futures._base import as_completed
from deepdiff.diff import DeepDiff
def main():
t1 = [[1, 2, 3, 9], [9, 8, 5, 9]]
t2 = [[1, 2, 4, 10], [4, 2, 5]]
diff = DeepDiff(t1, t2)
print(diff)
futures = []
with ProcessPoolExecutor(max_workers = 1) as executor:
futures.append(executor.submit(DeepDiff, t1, t2))
for future in as_completed(futures):
if future._exception is None and future._result is not None:
# DeepDiff 5.5.0
print(future._result)
else:
# DeepDiff 6.3.1
print(future._exception)
pass
if __name__ == '__main__':
main()
With DeepDiff 5.5.0 its output is:
{'values_changed': {'root[0][2]': {'new_value': 4, 'old_value': 3}, 'root[0][3]': {'new_value': 10, 'old_value': 9}, 'root[1][0]': {'new_value': 4, 'old_value': 9}, 'root[1][1]': {'new_value': 2, 'old_value': 8}}, 'iterable_item_removed': {'root[1][3]': 9}}
{'values_changed': {'root[0][2]': {'new_value': 4, 'old_value': 3}, 'root[0][3]': {'new_value': 10, 'old_value': 9}, 'root[1][0]': {'new_value': 4, 'old_value': 9}, 'root[1][1]': {'new_value': 2, 'old_value': 8}}, 'iterable_item_removed': {'root[1][3]': 9}}
With DeepDiff 6.3.1 its output is:
{'values_changed': {'root[0][2]': {'new_value': 4, 'old_value': 3}, 'root[0][3]': {'new_value': 10, 'old_value': 9}, 'root[1][0]': {'new_value': 4, 'old_value': 9}, 'root[1][1]': {'new_value': 2, 'old_value': 8}}, 'iterable_item_removed': {'root[1][3]': 9}}
Can't pickle local object 'DeepDiff.__init__.<locals>.<lambda>'
Originally posted by @behrm in #298 (comment)
Sep Dehpour commented
Hi @behrm
Thanks for bringing this issue to my attention again. Sometimes I fix the latest bug reports first and some tickets are forgotten.
I will take a look at it asap.