• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python failure.check函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.python.failure.check函数的典型用法代码示例。如果您正苦于以下问题:Python check函数的具体用法?Python check怎么用?Python check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _ebDeferSetUp

 def _ebDeferSetUp(self, failure, result):
     if failure.check(SkipTest):
         result.addSkip(self, self._getSkipReason(self.setUp, failure.value))
     else:
         result.addError(self, failure)
         if failure.check(KeyboardInterrupt):
             result.stop()
     return self.deferRunCleanups(None, result)
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:8,代码来源:_asynctest.py


示例2: _ebDeferSetUp

 def _ebDeferSetUp(self, failure, result):
     if failure.check(SkipTest):
         result.addSkip(self, self._getReason(failure))
     else:
         result.addError(self, failure)
         result.upDownError("setUp", failure, warn=False, printStatus=False)
         if failure.check(KeyboardInterrupt):
             result.stop()
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:8,代码来源:unittest.py


示例3: eb

 def eb(failure):
     # FIXME
     if failure.check(errors.NoMethodError) \
         or failure.check(flavors.NoSuchMethod):
         common.errorRaise("No method '%s' on manager." % methodName)
     elif failure.check(errors.RemoteRunError):
         common.errorRaise(log.getFailureMessage(failure))
     else:
         common.errorRaise(log.getFailureMessage(failure))
开发者ID:flyapen,项目名称:UgFlu,代码行数:9,代码来源:manager.py


示例4: eb

 def eb(failure):
     if failure.check(errors.NoMethodError):
         common.errorRaise("No method '%s' on component '%s'." % (
             methodName, p.componentId))
     elif failure.check(errors.SleepingComponentError):
         common.errorRaise(
             "Component '%s' is sleeping." % p.componentId)
     else:
         common.errorRaise(log.getFailureMessage(failure))
开发者ID:ylatuya,项目名称:Flumotion,代码行数:9,代码来源:component.py


示例5: eb

 def eb(failure):
     # FIXME
     if failure.check(errors.NoMethodError):
         common.errorRaise("No method '%s' on worker '%s'." % (methodName, workerName))
     elif failure.check(errors.SleepingComponentError):
         common.errorRaise("Component '%s' is sleeping." % p.componentId)
     elif failure.check(errors.RemoteRunError):
         common.errorRaise(log.getFailureMessage(failure))
     else:
         common.errorRaise(log.getFailureMessage(failure))
开发者ID:flyapen,项目名称:UgFlu,代码行数:10,代码来源:worker.py


示例6: _sendErrorAnswer

	def _sendErrorAnswer(self, failure, qid):
		del self._theirQuestions[qid]
		if failure.check(KnownError):
			body = failure.value[0]
			self._sendQANFrame(KnownErrorAnswer(body, qid))
		elif failure.check(defer.CancelledError):
			self._sendQANFrame(UnknownErrorAnswer("CancelledError", qid))
		else:
			self._logError("Peer's Question #%d caused uncaught "
				"exception" % (qid,), failure)
			# We intentionally do not reveal information about the
			# exception.
			self._sendQANFrame(UnknownErrorAnswer("Uncaught exception", qid))
开发者ID:ludios,项目名称:Minerva,代码行数:13,代码来源:qan.py


示例7: _error_handler

 def _error_handler(self, failure):
     if failure.check(tw_error.ConnectionRefusedError):
         self._on_disconnected()
         self.reconnect()
         raise NotConnectedError("Database connection refused.")
     elif (failure.check(httpclient.RequestError) and
           failure.value.cause and
           isinstance(failure.value.cause, tw_error.ConnectionDone)):
         self._on_disconnected()
         self.reconnect()
         raise NotConnectedError("Connection to the database was lost.")
     else:
         failure.raiseException()
开发者ID:f3at,项目名称:feat,代码行数:13,代码来源:driver.py


示例8: on_failure

    def on_failure(self, failure, request):
        """
        Handle exceptions raised during RestResource processing
        
        :param failure: ``twisted.python.failure.Failure`` instance
        :param request: ``twisted.web.server.Request`` instance
        """
        fq_name = self.__module__ + '.' + self.__class__.__name__
        file_path = abspath(inspect.getfile(self.__class__))

        if failure.check(CancelledError):
            # the request / deferred chain has been cancelled early.
            # doesn't matter if we respond no one is listening.
            rstr = err = 'Request was cancelled'
        elif failure.check(_DefGen_Return):
            failure.printBriefTraceback()
            err = dedent('''
                Received a Deferred Generator Response from Resource (%s)
                in the method:  [%s] ....................................
                This indicates you may be missing a yield statement and
                the decorator `@defer.inlineCallbacks`.
                File: %s
                
                If you do not have a yield statement, you should use a regular
                `return` statement and remove `defer.returnValue()`
            ''' % (fq_name, request.method_called, file_path)).strip()

            log.err(err + ' - ' + failure.getErrorMessage())
            rstr = self.ERROR_CLASS(
                INTERNAL_SERVER_ERROR,
                err,
                failure.getErrorMessage(),
                is_logged=False
            ).render(request)
        else:
            log.err('Exception in Resource (%s) [%s] <%s> - %s' % (
                fq_name, request.method_called, file_path, failure.getErrorMessage()))
            failure.printTraceback()
            rstr = self.ERROR_CLASS(
                INTERNAL_SERVER_ERROR,
                'Unhandled Error',
                'Exception in Resource (%s) [%s] <%s> - %s' % (
                    fq_name, request.method_called, file_path, failure.getTraceback()),
                is_logged=False
            ).render(request)

        if request.finished:
            return

        request.write(rstr)
        request.finish()
开发者ID:ajpuglis,项目名称:txrest,代码行数:51,代码来源:__init__.py


示例9: errback

 def errback(failure):
     try:
         if failure.check(ServerMessage):
             self.root.runCallback('msg', failure.getErrorMessage())
         self.root._failure()
     finally:
         self._startCall()
开发者ID:lueo,项目名称:Phoenix-Miner,代码行数:7,代码来源:RPCProtocol.py


示例10: _cbDeferRunCleanups

 def _cbDeferRunCleanups(self, cleanupResults, result):
     for flag, failure in cleanupResults:
         if flag == defer.FAILURE:
             result.addError(self, failure)
             if failure.check(KeyboardInterrupt):
                 result.stop()
             self._passed = False
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:7,代码来源:_asynctest.py


示例11: _eb

 def _eb(failure):
     if failure.check(*expectedFailures):
         return failure.value
     else:
         output = ('\nExpected: %r\nGot:\n%s'
                   % (expectedFailures, str(failure)))
         raise self.failureException(output)
开发者ID:AlexanderHerlan,项目名称:syncpy,代码行数:7,代码来源:_asynctest.py


示例12: _process

 def _process(self, failure, data_cache, exceptions):
     for (exc, key, max_count, init_backoff,
          incr_backoff, max_backoff) in exceptions:
         if failure.check(*exc) is not None:
             count = data_cache.get(key, 0) + 1
             if max_count is not None and count >= max_count:
                 zc.async.utils.tracelog.warning(
                     'Retry policy for job %r is not retrying after %d '
                     'counts of %s occurrences', self.parent, count, key)
                 return False
             elif count==1 or not count % self.log_every:
                 zc.async.utils.tracelog.warning(
                     'Retry policy for job %r requests another attempt '
                     'after %d counts of %s occurrences', self.parent,
                     count, key, exc_info=True)
             backoff = min(max_backoff,
                           (init_backoff + (count-1) * incr_backoff))
             if backoff:
                 time.sleep(backoff)
             data_cache[key] = count
             data_cache['last_' + key] = failure
             if 'first_active' not in data_cache:
                 data_cache['first_active'] = self.parent.active_start
             return True
     return False
开发者ID:upiq,项目名称:zc.async,代码行数:25,代码来源:job.py


示例13: expected

 def expected(self, failure):
     if self.errors is None:
         return True
     for error in self.errors:
         if failure.check(error):
             return True
     return False
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:7,代码来源:unittest.py


示例14: _defaultErrback

 def _defaultErrback(self, failure, request):
     if failure.check(errors.UnknownComponentError,
             errors.NotAuthenticatedError) is None:
         # If something else went wrong, we want to disconnect the client
         # and give them a 500 Internal Server Error.
         self._handleUnauthorized(request, http.INTERNAL_SERVER_ERROR)
     return failure
开发者ID:ylatuya,项目名称:Flumotion,代码行数:7,代码来源:http.py


示例15: testSTORESmallFailed

def testSTORESmallFailed(failure, msg, node, nKu, host, port):
    if failure.check('flud.protocol.FludCommUtil.BadCASKeyException'):
        print "%s" % msg
        return testSTOREBadKeyLarge(nKu, node, host, port)
    else:
        print "\nSTORESmall expected BadCASKeyException," \
                " but got a different failure:"
        raise failure
开发者ID:alenpeacock,项目名称:flud,代码行数:8,代码来源:FludPrimitiveTestFailure.py


示例16: matchException

        def matchException(failure):
            for errorState, backOff in self.backOffs.iteritems():
                if 'errorTypes' not in backOff:
                    continue
                if failure.check(*backOff['errorTypes']):
                    return errorState

            return 'other'
开发者ID:jchu,项目名称:twitty-twister,代码行数:8,代码来源:twitter.py


示例17: testVERIFYBadKeyFailed

def testVERIFYBadKeyFailed(failure, msg, node, nKu, host, port):
    if failure.check('flud.protocol.FludCommUtil.NotFoundException'):
        print "%s" % msg
        return testDELETEBadKey(nKu, node, host, port)
    else:
        print "\nVERIFYBadKey expected NotFoundException," \
                " but got a different failure:"
        raise failure
开发者ID:alenpeacock,项目名称:flud,代码行数:8,代码来源:FludPrimitiveTestFailure.py


示例18: testRETRIEVENotFoundFailed

def testRETRIEVENotFoundFailed(failure, msg, node, nKu, host, port):
    if failure.check('flud.protocol.FludCommUtil.NotFoundException'):
        print "%s" % msg
        return testRETRIEVEIllegalPath(nKu, node, host, port)
    else:
        print "\nRETRIEVENotFound expected NotFoundException," \
                " but got a different failure:"
        raise failure
开发者ID:alenpeacock,项目名称:flud,代码行数:8,代码来源:FludPrimitiveTestFailure.py


示例19: testVERIFYBadLengthFailed

def testVERIFYBadLengthFailed(failure, msg, node, nKu, host, port):
    if failure.check('flud.protocol.FludCommUtil.BadRequestException'):
        print "%s" % msg
        return testVERIFYBadKey(nKu, node, host, port)
    else:
        print "\nVERIFYBadLength expected BadRequestException," \
                " but got a different failure:"
        raise failure
开发者ID:alenpeacock,项目名称:flud,代码行数:8,代码来源:FludPrimitiveTestFailure.py


示例20: errback

 def errback(failure):
     if not self.currentlyAsking:
         return
     self.currentlyAsking = False
     if failure.check(ServerMessage):
         self.root.runCallback('msg', failure.getErrorMessage())
     self.root._failure()
     self._startCall()
开发者ID:jrmithdobbs,项目名称:phoenix-miner,代码行数:8,代码来源:RPCProtocol.py



注:本文中的twisted.python.failure.check函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python failure.startDebugMode函数代码示例发布时间:2022-05-27
下一篇:
Python dist.setup函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap