当前位置: 首页>>代码示例>>Python>>正文


Python Failure.getBriefTraceback方法代码示例

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


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

示例1: log

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getBriefTraceback [as 别名]
    def log(self, category, eventDict):
        """
        Log an event.

        @param category: A short string identifying the type of log event.
            The receiving log server may use this to collect all messages of the
            same category in their own log files.
        @type category: C{bytes}

        @param eventDict: The event dictionary. As this is serialized to JSON
            (see L{serialize}), for complex values, you may want to render them
            to a string before adding them to the event dictionary.
        @type eventDict: C{dict}
        """
        self.augment(eventDict)
        data = self.serialize(category, eventDict)

        try:
            self.socket.send(data)
        except:
            failure = Failure()
            why = "Failed to send udplog message"
            data = self.serializeFailure(category, eventDict, len(data),
                                         failure, why)
            try:
                self.socket.send(data)
            except Exception:
                import sys
                text = why + '\n' + failure.getBriefTraceback()
                print >> sys.stderr, text
开发者ID:mochi,项目名称:udplog,代码行数:32,代码来源:udplog.py

示例2: test_writeFailure

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getBriefTraceback [as 别名]
    def test_writeFailure(self, logger):
        """
        L{writeFailure} writes a L{Failure} to the log.
        """
        if Failure is None:
            raise SkipTest("Twisted unavailable")

        try:
            raise RuntimeError("because")
        except:
            failure = Failure()
            expectedTraceback = failure.getBriefTraceback()
            writeFailure(failure, logger)
        message = logger.messages[0]
        assertContainsFields(
            self,
            message,
            {
                "message_type": "eliot:traceback",
                "exception": RuntimeError,
                "reason": failure.value,
                "traceback": expectedTraceback,
            },
        )
        logger.flushTracebacks(RuntimeError)
开发者ID:ClusterHQ,项目名称:eliot,代码行数:27,代码来源:test_traceback.py

示例3: receiveDirectMessage

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getBriefTraceback [as 别名]
 def receiveDirectMessage(self, senderName, messageText, metadata=None):
     cmdline = string.split(messageText, ' ', 1)
     if len(cmdline) == 1:
         cmd, arg = cmdline[0], ''
     else:
         cmd, arg = cmdline
     try:
         getattr(self, "bot_%s" % cmd)(senderName, arg, metadata)
     except:
         f = Failure()
         self.voice.directMessage(senderName, f.getBriefTraceback())
开发者ID:fxia22,项目名称:ASM_xf,代码行数:13,代码来源:botbot.py

示例4: _do_get_connection

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getBriefTraceback [as 别名]
def _do_get_connection(account, conductor, ready, retries_left, backoff):
    this_ready = defer.Deferred()
    factory = ImapClientFactory(account, conductor, this_ready)
    factory.connect()
    try:
        conn = yield this_ready
        # yay - report we are good and tell the real callback we have it.
        account.reportStatus(brat.EVERYTHING, brat.GOOD)
        ready.callback(conn)
    except Exception, exc:
        fail = Failure()
        logger.debug("first chance connection error handling: %s\n%s", fail.getErrorMessage(), fail.getBriefTraceback())
        retries_left -= 1
        if retries_left <= 0:
            ready.errback(fail)
        else:
            status = failure_to_status(fail)
            account.reportStatus(**status)
            logger.warning("Failed to connect, will retry after %s secs: %s", backoff, fail.getErrorMessage())
            next_backoff = min(backoff * 2, MAX_BACKOFF)  # magic number
            conductor.reactor.callLater(
                backoff, _do_get_connection, account, conductor, ready, retries_left, next_backoff
            )
开发者ID:dineshkummarc,项目名称:raindrop,代码行数:25,代码来源:imap.py


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