Skip to content

Server instance not pickle-able, PerspectiveManager was pickle-able #2853

Description

@timkpaine

Feature Request

Description of Problem:

Many web server setups use a process pool and send across a pickled instance of the primary web server, and some (such as ray serve) ship an instantiated web server not just to another process, but potentially to a completely different machine.

Table and View have never been pickle-able, nor is there any expectation that they be so, but PerspectiveManager used to be pickle-able, and its replacement, Server is not. Using cloudpickle (but same results for builtin pickle):

Works (perspective<3)

from cloudpickle import dumps
from perspective import PerspectiveManager
dumps(PerspectiveManager())

Doesn't work (perspective>=3)

from cloudpickle import dumps
from perspective import Server
dumps(Server())
Traceback (most recent call last):
  File "/Users/timkpaine/Developer/tmp.py", line 4, in <module>
    dumps(Server())
  File "/opt/homebrew/lib/python3.11/site-packages/cloudpickle/cloudpickle.py", line 1479, in dumps
    cp.dump(obj)
  File "/opt/homebrew/lib/python3.11/site-packages/cloudpickle/cloudpickle.py", line 1245, in dump
    return super().dump(obj)
           ^^^^^^^^^^^^^^^^^
TypeError: cannot pickle 'builtins.PySyncServer' object

Potential Solutions:

The workaround is to defer server construction until e.g. the first request (as we do here), but this is a bit clunky. It would be good if a Server instance with no tables was pickle-able, or if we could establish a better pattern

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

    Labels

    enhancementFeature requests or improvements

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions