def _unpickle(cls, userModule, fileHandle, config):
        """
        Unpickles an object graph from the given file handle while loading symbols \
        referencing the __main__ module from the given userModule instead.

        :param userModule:
        :param fileHandle: An open, binary-mode file handle.
        :returns:
        """
        
        def filter_main(module_name, class_name):
            try:
                if module_name == '__main__':
                    return getattr(userModule, class_name)
                else:
                    return getattr(importlib.import_module(module_name), class_name)
            except:
                if module_name == '__main__':
                    logger.debug('Failed getting %s from module %s.', class_name, userModule)
                else:
                    logger.debug('Failed getting %s from module %s.', class_name, module_name)
                raise

        try:
            unpickler = pickle.Unpickler(fileHandle)
            # In Python 2 with cPickle we set "find_global"
            unpickler.find_global = filter_main
        except AttributeError:
            # In Python 3 find_global isn't real and we are supposed to
            # subclass unpickler and override find_class. We can't just replace
            # it. But with cPickle in Pyhton 2 we can't subclass Unpickler.
            
            class FilteredUnpickler(pickle.Unpickler):
                def find_class(self, module, name):
                    return filter_main(module, name)
                    
            unpickler = FilteredUnpickler(fileHandle)
            
        runnable = unpickler.load()
        assert isinstance(runnable, BaseJob)
        runnable._config = config
        return runnable
def _unpickle ( cls , userModule , fileHandle , config ) : def filter_main ( module_name , class_name ) : try : if module_name == '__main__' : return getattr ( userModule , class_name ) else : return getattr ( importlib . import_module ( module_name ) , class_name ) except : if module_name == '__main__' : logger . debug ( 'Failed getting %s from module %s.' , class_name , userModule ) else : logger . debug ( 'Failed getting %s from module %s.' , class_name , module_name ) raise try : unpickler = pickle . Unpickler ( fileHandle ) unpickler . find_global = filter_main except AttributeError : class FilteredUnpickler ( pickle . Unpickler ) : def find_class ( self , module , name ) : return filter_main ( module , name ) unpickler = FilteredUnpickler ( fileHandle ) runnable = unpickler . load ( ) assert isinstance ( runnable , BaseJob ) runnable . _config = config return runnable
Unpickles an object graph from the given file handle while loading symbols \
        referencing the __main__ module from the given userModule instead.

        :param userModule:
        :param fileHandle: An open, binary-mode file handle.
        :returns: