當前位置: 首頁>>代碼示例>>Python>>正文


Python traceback.format_stack方法代碼示例

本文整理匯總了Python中traceback.format_stack方法的典型用法代碼示例。如果您正苦於以下問題:Python traceback.format_stack方法的具體用法?Python traceback.format_stack怎麽用?Python traceback.format_stack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在traceback的用法示例。


在下文中一共展示了traceback.format_stack方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: log

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def log(msg, msgx='', level=logging.INFO, need_tb=False):
    """
    Logging in UCC Config Module.
    :param msg: message content
    :param msgx: detail info.
    :param level: logging level
    :param need_tb: if need logging traceback
    :return:
    """
    global LOGGING_STOPPED
    if LOGGING_STOPPED:
        return

    msgx = ' - ' + msgx if msgx else ''
    content = 'UCC Config Module: %s%s' % (msg, msgx)
    if need_tb:
        stack = ''.join(traceback.format_stack())
        content = '%s\r\n%s' % (content, stack)
    stulog.logger.log(level, content, exc_info=1) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:21,代碼來源:config.py

示例2: error

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def error(message: str, *, stack: str = None, replace: bool = False) -> None:
    """Display an error message.

    Args:
        message: The message to show.
        stack: The stack trace to show (if any).
        replace: Replace existing messages which are still being shown.
    """
    if stack is None:
        stack = ''.join(traceback.format_stack())
        typ = 'error'
    else:
        typ = 'error (from exception)'
    _log_stack(typ, stack)
    log.message.error(message)
    global_bridge.show(usertypes.MessageLevel.error, message, replace) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:18,代碼來源:message.py

示例3: _do_get

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def _do_get(self):
        if self._checked_out:
            if self._checkout_traceback:
                suffix = ' at:\n%s' % ''.join(
                    chop_traceback(self._checkout_traceback))
            else:
                suffix = ''
            raise AssertionError("connection is already checked out" + suffix)

        if not self._conn:
            self._conn = self._create_connection()

        self._checked_out = True
        if self._store_traceback:
            self._checkout_traceback = traceback.format_stack()
        return self._conn 
開發者ID:jpush,項目名稱:jbox,代碼行數:18,代碼來源:pool.py

示例4: thread_stacktraces

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def thread_stacktraces():
  """
  Provides a dump of the stacktrace information for all active threads.

  :returns: **dict** that maps thread names to their stacktrace
  """

  stacktraces = {}

  for thread in threading.enumerate():
    frame = sys._current_frames().get(thread.ident, None)

    if frame:
      stacktraces[thread.name] = ''.join(traceback.format_stack(frame))
    else:
      stacktraces[thread.name] = 'No traceback available'

  return stacktraces 
開發者ID:torproject,項目名稱:stem,代碼行數:20,代碼來源:output.py

示例5: tryLock

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def tryLock(self, timeout=None, id=None):
        if timeout is None:
            locked = QtCore.QMutex.tryLock(self)
        else:
            locked = QtCore.QMutex.tryLock(self, timeout)

        if self.debug and locked:
            self.l.lock()
            try:
                if id is None:
                    self.tb.append(''.join(traceback.format_stack()[:-1]))
                else:
                    self.tb.append("  " + str(id))
                #print 'trylock', self, len(self.tb)
            finally:
                self.l.unlock()
        return locked 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:19,代碼來源:mutex.py

示例6: _startRunCallbacks

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def _startRunCallbacks(self, result):
        if self.called:
            if self._suppressAlreadyCalled:
                self._suppressAlreadyCalled = False
                return
            if self.debug:
                if self._debugInfo is None:
                    self._debugInfo = DebugInfo()
                extra = "\n" + self._debugInfo._getDebugTracebacks()
                raise AlreadyCalledError(extra)
            raise AlreadyCalledError
        if self.debug:
            if self._debugInfo is None:
                self._debugInfo = DebugInfo()
            self._debugInfo.invoker = traceback.format_stack()[:-2]
        self.called = True
        self.result = result
        self._runCallbacks() 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:defer.py

示例7: inspect_threads

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def inspect_threads(thread_names=[]):
    """inspect_threads() -> {thread_name: {"locals": {}, "stack": ""}} : return threads' locals and stack"""
    import threading
    import sys
    import traceback
    pylane_thread_name = "pylane-shell-thread"
    stacks = {}
    frames = sys._current_frames()
    threads = threading.enumerate()
    for thread in threads:
        if thread.name == pylane_thread_name:
            continue
        if thread_names and thread.name not in thread_names:
            continue
        frame = frames.get(thread.ident)
        stack = ''.join(traceback.format_stack(frame)) if frame else ''
        stacks[thread.name] = {
            "locals": frame.f_locals,
            "stack": stack
        }
    return stacks 
開發者ID:NtesEyes,項目名稱:pylane,代碼行數:23,代碼來源:help_functions.py

示例8: format_error

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def format_error(e):
    # errback automatically wraps everything in a Twisted Failure
    if isinstance(e, failure.Failure):
        e = e.value

    if isinstance(e, str):
        err_string = e
    elif six.PY2:
        err_string = traceback.format_exc(e).rstrip()
    else:
        err_string = ''.join(traceback.format_exception(type(e), e, e.__traceback__)).rstrip()

    if err_string == 'None':
        # Reasonable heuristic for exceptions that were created by hand
        last = traceback.format_stack()[-2]
        err_string = '{}\n  {}'.format(e, last)
    # Quick and dirty hack for now.
    err_string = err_string.replace('Connection to the other side was lost in a non-clean fashion', 'Connection to the other side was lost in a non-clean fashion (HINT: this generally actually means we got a connection refused error. Check that the remote is actually running.)')
    return error.Error(err_string) 
開發者ID:openai,項目名稱:universe,代碼行數:21,代碼來源:__init__.py

示例9: retain_error

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def retain_error(self, error, frame=None):
        """
        Adds details of an error to the report.

        :param error: The error exception to add to the report.
        """
        if frame is None:
            stack = traceback.format_exc()
            self.labels.add("@iopipe/error")
        else:
            stack = "\n".join(traceback.format_stack(frame))
            self.labels.add("@iopipe/timeout")
        details = {
            "name": type(error).__name__,
            "message": "{}".format(error),
            "stack": stack,
        }
        self.report["errors"] = details 
開發者ID:iopipe,項目名稱:iopipe-python,代碼行數:20,代碼來源:report.py

示例10: debug_signal

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def debug_signal(signum, frame):
    import sys, traceback
    for thread_id, stack in sys._current_frames().iteritems():
        print('Thread id: %s\n%s' % (thread_id, ''.join(traceback.format_stack(stack)))) 
開發者ID:sippy,項目名稱:rtp_cluster,代碼行數:6,代碼來源:rtp_cluster.py

示例11: _assert

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def _assert(condition):
    if not condition:
        sys.stderr.write(''.join(traceback.format_stack()[:-1]))
        comm.Abort() 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:6,代碼來源:mpi.py

示例12: log_expect_failure

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def log_expect_failure(self, expected_pattern):
        self.write_result("\n\n*** Did not find expected pattern {}\n\n".format(expected_pattern))
        # Generate a call stack in rift_expect.log for easier debugging
        # But pytest call stacks are very deep, so only show the "interesting" lines
        for line in traceback.format_stack():
            if "tests/" in line:
                self.write_result(line.strip())
                self.write_result("\n") 
開發者ID:brunorijsman,項目名稱:rift-python,代碼行數:10,代碼來源:rift_expect_session.py

示例13: expect_failure

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def expect_failure(self, msg):
        self._results_file.write(msg + "\n\n")
        # Generate a call stack in rift_expect.log for easier debugging
        # But pytest call stacks are very deep, so only show the "interesting" lines
        for line in traceback.format_stack():
            if "tests/" in line:
                self._results_file.write(line.strip())
                self._results_file.write("\n")
        assert False, msg + " (see log_expect.log for details)" 
開發者ID:brunorijsman,項目名稱:rift-python,代碼行數:11,代碼來源:log_expect_session.py

示例14: log_expect_failure

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def log_expect_failure(self):
        self.write_result("\n\n*** Did not find expected pattern\n\n")
        # Generate a call stack in the log file for easier debugging
        for line in traceback.format_stack():
            self.write_result(line.strip())
            self.write_result("\n") 
開發者ID:brunorijsman,項目名稱:rift-python,代碼行數:8,代碼來源:config_generator.py

示例15: log_stack

# 需要導入模塊: import traceback [as 別名]
# 或者: from traceback import format_stack [as 別名]
def log_stack(self, signal, frame):
        """Signal handler to log the stack trace of the current thread.

        For use with `set_blocking_signal_threshold`.
        """
        gen_log.warning('IOLoop blocked for %f seconds in\n%s',
                        self._blocking_signal_threshold,
                        ''.join(traceback.format_stack(frame))) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:10,代碼來源:ioloop.py


注:本文中的traceback.format_stack方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。