Skip to content

Classes with cached_property can't be cloudpickled #438

Open
@durumu

Description

@durumu

I believe this is a bug.

Here is an example:

from functools import cached_property
import pickle
import cloudpickle


class MyExample:
    def __init__(self, foo):
        self.foo = foo

    @cached_property
    def bar(self) -> int:
        return self.foo * 3


example = MyExample(2)
pickle.dumps(example)      # works
cloudpickle.dumps(example) # crashes

This fails with TypeError: cannot pickle '_thread.RLock' object.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions