Skip to content

Support for pickling functions within a class defined outside of __main__? #175

Description

@mlucas-NU

Cloudpickle's ability to serialize instantiated classes and their member functions is a huge advantage over cloudpickle alternatives. Unfortunately, this feature seems limited heavily to the check for instantiated_class.__module__ == '__main__'.

One hacky solution is to set __module__ in the class definition:

class SomeFunClass(object):
__module__ = '__main__'
# Rest of the class definition

But this could cause problems with any code that relies on a proper value for __module__. Is there another solution I'm not seeing?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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