本文整理匯總了Python中asyncore.compact_traceback方法的典型用法代碼示例。如果您正苦於以下問題:Python asyncore.compact_traceback方法的具體用法?Python asyncore.compact_traceback怎麽用?Python asyncore.compact_traceback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類asyncore
的用法示例。
在下文中一共展示了asyncore.compact_traceback方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle_read
# 需要導入模塊: import asyncore [as 別名]
# 或者: from asyncore import compact_traceback [as 別名]
def handle_read(self):
try:
self.recv(8192)
except (OSError, socket.error):
return
self.lock.acquire()
try:
for thunk in self.thunks:
try:
thunk()
except:
nil, t, v, tbinfo = asyncore.compact_traceback()
self.log_info(
'exception in trigger thunk: (%s:%s %s)' %
(t, v, tbinfo))
self.thunks = []
finally:
self.lock.release()
示例2: test_compact_traceback
# 需要導入模塊: import asyncore [as 別名]
# 或者: from asyncore import compact_traceback [as 別名]
def test_compact_traceback(self):
try:
raise Exception("I don't like spam!")
except:
real_t, real_v, real_tb = sys.exc_info()
r = asyncore.compact_traceback()
else:
self.fail("Expected exception")
(f, function, line), t, v, info = r
self.assertEqual(os.path.split(f)[-1], 'test_asyncore.py')
self.assertEqual(function, 'test_compact_traceback')
self.assertEqual(t, real_t)
self.assertEqual(v, real_v)
self.assertEqual(info, '[%s|%s|%s]' % (f, function, line))