python check if type is serializable

81 Views Asked by At

Trying to use a distributed cluster computing framework, i want to pre-validate a graph before running it for non serializable types.

Presume i have the following class:

class Human:
    def __init__(self, name):
        self.name = name

I know that the class/type Human is a serializable type, but how could i check that in code without needing an instance of that type? In contrast how can i know when a type (like a DbConnection) is not serializable?

I tried a combination of inspect.signature, typings.getargs, typings.getorigin such that i could get the object signature, but i cannot whitelist/blacklist all possible types. I also expect that looking just at an object signature is not enough to determine if an object is serializable

0

There are 0 best solutions below