コード例 #1
0
ファイル: __init__.py プロジェクト: andrew-d/evergreen
    def load_module(self, fullname):
        if fullname in sys.modules:
            return sys.modules[fullname]
        modname = fullname.split('.', self.prefix_cutoff)[self.prefix_cutoff]
        for path in self.module_choices:
            realname = path % modname
            try:
                __import__(realname)
            except ImportError:
                exc_type, exc_value, tb = sys.exc_info()
                # since we only establish the entry in sys.modules at the
                # very this seems to be redundant, but if recursive imports
                # happen we will call into the move import a second time.
                # On the second invocation we still don't have an entry for
                # fullname in sys.modules, but we will end up with the same
                # fake module name and that import will succeed since this
                # one already has a temporary entry in the modules dict.
                # Since this one "succeeded" temporarily that second
                # invocation now will have created a fullname entry in
                # sys.modules which we have to kill.
                sys.modules.pop(fullname, None)

                # If it's an important traceback we reraise it, otherwise
                # we swallow it and try the next choice.  The skipped frame
                # is the one from __import__ above which we don't care about
                if self.is_important_traceback(realname, tb):
                    six.reraise(exc_type, exc_value, tb.tb_next)
                continue
            module = sys.modules[fullname] = sys.modules[realname]
            if '.' not in modname:
                setattr(sys.modules[self.wrapper_module], modname, module)
            return module
        raise ImportError('No module named %s' % fullname)
コード例 #2
0
ファイル: __init__.py プロジェクト: kingxsp/evergreen
    def load_module(self, fullname):
        if fullname in sys.modules:
            return sys.modules[fullname]
        modname = fullname.split('.', self.prefix_cutoff)[self.prefix_cutoff]
        for path in self.module_choices:
            realname = path % modname
            try:
                __import__(realname)
            except ImportError:
                exc_type, exc_value, tb = sys.exc_info()
                # since we only establish the entry in sys.modules at the
                # very this seems to be redundant, but if recursive imports
                # happen we will call into the move import a second time.
                # On the second invocation we still don't have an entry for
                # fullname in sys.modules, but we will end up with the same
                # fake module name and that import will succeed since this
                # one already has a temporary entry in the modules dict.
                # Since this one "succeeded" temporarily that second
                # invocation now will have created a fullname entry in
                # sys.modules which we have to kill.
                sys.modules.pop(fullname, None)

                # If it's an important traceback we reraise it, otherwise
                # we swallow it and try the next choice.  The skipped frame
                # is the one from __import__ above which we don't care about
                if self.is_important_traceback(realname, tb):
                    six.reraise(exc_type, exc_value, tb.tb_next)
                continue
            module = sys.modules[fullname] = sys.modules[realname]
            if '.' not in modname:
                setattr(sys.modules[self.wrapper_module], modname, module)
            return module
        raise ImportError('No module named %s' % fullname)
コード例 #3
0
ファイル: tasks.py プロジェクト: kingxsp/evergreen
 def just_raise(*a, **kw):
     try:
         if throw_args:
             six.reraise(throw_args[0], throw_args[1], throw_args[2])
         else:
             raise TaskExit()
     finally:
         self._exit_event.set()
コード例 #4
0
 def just_raise(*a, **kw):
     try:
         if throw_args:
             six.reraise(throw_args[0], throw_args[1],
                         throw_args[2])
         else:
             raise TaskExit()
     finally:
         self._exit_event.set()
コード例 #5
0
 def raise_(self):
     six.reraise(self.type, self.value, self.traceback)
コード例 #6
0
ファイル: util.py プロジェクト: kingxsp/evergreen
 def _get_result(self):
     self._used = True
     if self._exception is not None:
         six.reraise(type(self._exception), self._exception)
     else:
         return self._result
コード例 #7
0
ファイル: util.py プロジェクト: kingxsp/evergreen
 def _get_result(self):
     self._used = True
     if self._exception is not None:
         six.reraise(type(self._exception), self._exception)
     else:
         return self._result