예제 #1
0
    def __getstate__(self):
        """Prepare object data for serialization.

    This converts any instance methods to the bound object (if any) and the
    method name.

    """
        f = self.f
        if getattr(f, 'func_name', None) == '<lambda>':
            raise PicklingError("Lambda functions can not be serialized")
        isbound = isinstance(f, types.MethodType)
        if isbound:
            if f.__self__ is None:
                raise PicklingError("Unbound methods can not be serialized")
            f = (f.__self__, f.__func__.__name__)
        return (isbound, f, self.args, self.kw)
예제 #2
0
    def __getstate__(self):
        if not self.feature_extractors_fqname:
            raise PicklingError("Can't pickle a Featurizer without a fully-"
                                "qualified name from which to restore"
                                " extractors")

        state = self.__dict__.copy()
        for attr_name in [
                'featurized', 'all_feature_extractors',
                '_selected_base_extractors', '_unselected_base_extractors',
                '_conjoined_extractors'
        ]:
            del state[attr_name]
        state['selected_features'] = self.get_selected_features(
            self.feature_name_dictionary)
        return state
예제 #3
0
 def __getstate__(self):
     # disallow persistent storage
     raise PicklingError("Temporary objects can't be pickled")
예제 #4
0
 def __getstate__(self):
     try:
         return dict(self.nodes.items())
     except Exception as e:
         raise PicklingError('Unable to pickle: {}'.format(e))
예제 #5
0
파일: core.py 프로젝트: solebox/WorQ
 def persistent_id(obj):
     if isinstance(obj, Deferred):
         raise PicklingError('%s cannot be serialized' % obj)
     return None
예제 #6
0
 def __getstate__(self):  # pragma: no cover
     raise PicklingError("Node cannot be serialized")
예제 #7
0
 def raise_error():
     raise PicklingError("SomeMessage")