本文整理汇总了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
示例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)
示例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())
示例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
)