Skip to content

Everything is pickled twice #1371

@crusaderky

Description

@crusaderky
import distributed
import logging

def log(msg):
    with open('poc.log', 'a') as fh:
        fh.write(msg + '\n')

class Dummy:
    def __getstate__(self):
        log('pickle')
        return self.__dict__
    
    def __setstate__(self, state):
        self.__dict__ = state
        log('unpickle')

cluster = distributed.LocalCluster(n_workers=1, threads_per_worker=1, processes=True)
client = distributed.Client(cluster)

client.submit(lambda x: x, Dummy()).result()

In poc.log:

pickle
pickle
unpickle
pickle
pickle
unpickle

Am I missing something obvious?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions