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


Python traceback.print_stack方法代码示例

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


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

示例1: scatter_graph

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def scatter_graph(self):
        """
        Show agent locations.
        """
        if self.has_disp():
            try:
                data = self.plot_data()
                scatter_plot = disp.ScatterPlot(
                    self.plot_title, data,
                    int(self.width), int(self.height),
                    anim=True, data_func=self.plot_data,
                    is_headless=self.headless(),
                    attrs=self.attrs)
                scatter_plot.show()
                return scatter_plot
            except ValueError as e:  # Exception as e:
                self.user.tell("Error when drawing scatter plot: " + str(e))
                traceback.print_stack()
        else:
            return None 
开发者ID:gcallah,项目名称:indras_net,代码行数:22,代码来源:env.py

示例2: go

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def go(self):
        if self.ed.my_ident != get_ident():
            print(datetime.now(), 'EventDispatcher2: Timer.go() from wrong thread, expect Bad Stuff[tm] to happen')
            print('-' * 70)
            traceback.print_stack(file = sys.stdout)
            print('-' * 70)
            sys.stdout.flush()
        if not self.abs_time:
            if self.randomize_runs != None:
                ival = self.randomize_runs(self.ival)
            else:
                ival = self.ival
            self.etime = self.itime.getOffsetCopy(ival)
        else:
            self.etime = self.ival
            self.ival = None
            self.nticks = 1
        heappush(self.ed.tlisteners, self)
        return 
开发者ID:sippy,项目名称:rtp_cluster,代码行数:21,代码来源:EventDispatcher.py

示例3: formatException

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def formatException(self, ei):
        """
        Format and return the specified exception information as a string.

        This default implementation just uses
        traceback.print_exception()
        """
        sio = io.StringIO()
        tb = ei[2]
        # See issues #9427, #1553375. Commented out for now.
        #if getattr(self, 'fullstack', False):
        #    traceback.print_stack(tb.tb_frame.f_back, file=sio)
        traceback.print_exception(ei[0], ei[1], tb, None, sio)
        s = sio.getvalue()
        sio.close()
        if s[-1:] == "\n":
            s = s[:-1]
        return s 
开发者ID:war-and-code,项目名称:jawfish,代码行数:20,代码来源:__init__.py

示例4: on_timeout

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def on_timeout():
    logger.debug("cli timeout ")
    # Timeout should have been handled by the orchestrator, if the cli timeout
    # has been reached, something is probably wrong : dump threads.
    for th in threading.enumerate():
        print(th)
        traceback.print_stack(sys._current_frames()[th.ident])
        print()

    if orchestrator is None:
        logger.debug("cli timeout with no orchestrator ?")
        return
    global timeout_stopped
    timeout_stopped = True

    orchestrator.stop_agents(20)
    orchestrator.stop()
    _results("TIMEOUT")
    sys.exit(0) 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:21,代码来源:orchestrator.py

示例5: on_timeout

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def on_timeout():
    logger.debug("cli timeout ")
    # Timeout should have been handled by the orchestrator, if the cli timeout
    # has been reached, something is probably wrong : dump threads.
    for th in threading.enumerate():
        print(th)
        traceback.print_stack(sys._current_frames()[th.ident])
        print()

    if orchestrator is None:
        logger.debug("cli timeout with no orchestrator ?")
        return
    global timeout_stopped
    timeout_stopped = True
    # Stopping agents can be rather long, we need a big timeout !
    logger.debug("stop agent on cli timeout ")
    orchestrator.stop_agents(20)
    logger.debug("stop orchestrator on cli timeout ")
    orchestrator.stop()
    _results("TIMEOUT")
    # sys.exit(0)
    os._exit(2) 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:24,代码来源:solve.py

示例6: on_timeout

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def on_timeout():
    if orchestrator is None:
        return
    # Timeout should have been handled by the orchestrator, if the cli timeout
    # has been reached, something is probably wrong : dump threads.
    for th in threading.enumerate():
        print(th)
        traceback.print_stack(sys._current_frames()[th.ident])
        print()
    if orchestrator is None:
        logger.debug("cli timeout with no orchestrator ?")
        return
    global timeout_stopped
    timeout_stopped = True

    # Stopping agents can be rather long, we need a big timeout !
    orchestrator.stop_agents(20)
    orchestrator.stop()
    _results("TIMEOUT")
    sys.exit(0) 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:22,代码来源:run.py

示例7: on_timeout

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def on_timeout():
    global result, output_file
    global start_t
    duration = time.time() - start_t

    print("TIMEOUT when distributing")
    logger.info("cli timeout when distributing")
    for th in threading.enumerate():
        print(th)
        traceback.print_stack(sys._current_frames()[th.ident])

    result["status"] =  "TIMEOUT"
    result["inputs"]["duration"] = duration

    if output_file is not None:
        with open(output_file, encoding="utf-8", mode="w") as fo:
            fo.write(yaml.dump(result))
    print(yaml.dump(result))

    #os._exit(0)
    sys.exit(0) 
开发者ID:Orange-OpenSource,项目名称:pyDcop,代码行数:23,代码来源:distribute.py

示例8: lock

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def lock(self, id=None):
        c = 0
        waitTime = 5000  # in ms
        while True:
            if self.tryLock(waitTime, id):
                break
            c += 1
            if self.debug:
                self.l.lock()
                try:
                    print("Waiting for mutex lock (%0.1f sec). Traceback follows:" 
                          % (c*waitTime/1000.))
                    traceback.print_stack()
                    if len(self.tb) > 0:
                        print("Mutex is currently locked from:\n")
                        print(self.tb[-1])
                    else:
                        print("Mutex is currently locked from [???]")
                finally:
                    self.l.unlock()
        #print 'lock', self, len(self.tb) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:23,代码来源:mutex.py

示例9: findCaller

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def findCaller(self, stack_info=False):
        frame = sys._getframe(2)
        f_to_skip = {
            func for func in dir(Logger) if callable(getattr(Logger, func))
        }.union({func for func in dir(QKCLogger) if callable(getattr(QKCLogger, func))})

        while frame:
            code = frame.f_code
            if _LOGGING_FILE_PREFIX not in code.co_filename and (
                "utils.py" not in code.co_filename or code.co_name not in f_to_skip
            ):
                if not stack_info:
                    return (code.co_filename, frame.f_lineno, code.co_name, "")
                else:
                    sinfo = None
                    if stack_info:
                        out = io.StringIO()
                        out.write(u"Stack (most recent call last):\n")
                        traceback.print_stack(frame, file=out)
                        sinfo = out.getvalue().rstrip(u"\n")
                    return (code.co_filename, frame.f_lineno, code.co_name, sinfo)
            frame = frame.f_back 
开发者ID:QuarkChain,项目名称:pyquarkchain,代码行数:24,代码来源:utils.py

示例10: emit

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def emit(self, record):
		"""
		Emit a record.

		If the stream was not opened because 'delay' was specified in the
		constructor, open it before calling the superclass's emit.
		"""
		failures = 0
		while failures < 3:
			try:
				self.stream_emit(record, record.name)
				break
			except:
				failures += 1
		else:
			traceback.print_stack()
			print("Error writing to file?")


		self.close() 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:22,代码来源:logSetup.py

示例11: delete_db_session

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def delete_db_session(postfix="", flask_sess_if_possible=True):
	if flags.IS_FLASK and flask_sess_if_possible:
		# No need to do anything with flask sess
		return

	cpid = multiprocessing.current_process().name
	ctid = threading.current_thread().name
	csid = "{}-{}-{}".format(cpid, ctid, postfix)


	# print("Releasing session for thread: %s" % csid)
	# print(traceback.print_stack())
	# print("==========================")

	if csid in SESSIONS:
		with SESSION_LOCK:
			# check if the session was created while
			# we were waiting for the lock
			if not csid in SESSIONS:
				return
			SESSIONS[csid][1].close()
			del SESSIONS[csid]
			# print("Deleted session for id: ", csid) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:25,代码来源:db_engine.py

示例12: handle_error

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def handle_error(self, wrapper, exception, traceback_):
        print >> sys.stderr
        print >> sys.stderr, "---- location:"
        traceback.print_stack()
        print >> sys.stderr, "---- error:"
        traceback.print_tb(traceback_)
        try:
            stack = wrapper.stack_where_defined
        except AttributeError:
            print >> sys.stderr, "??:??: %s / %r" % (wrapper, exception)
        else:
            stack = list(stack)
            stack.reverse()
            for (filename, line_number, function_name, text) in stack:
                file_dir = os.path.dirname(os.path.abspath(filename))
                if file_dir.startswith(this_script_dir):
                    print >> sys.stderr, "%s:%i: %r" % (os.path.join("..", "bindings", "python", os.path.basename(filename)),
                                                        line_number, exception)
                    break
        return True 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:22,代码来源:ns3modulegen.py

示例13: exit_and_msg

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def exit_and_msg(msg):
    traceback.print_stack()

    exit_msg = "Service Stop by: " + msg
    logging.exception(exit_msg)

    # To make sure of terminating process exactly
    os.killpg(0, signal.SIGKILL)
    time.sleep(5)

    os.kill(os.getpid(), signal.SIGKILL)
    time.sleep(5)

    os._exit(-1)
    time.sleep(5)

    sys.exit(-1) 
开发者ID:icon-project,项目名称:loopchain,代码行数:19,代码来源:__init__.py

示例14: make_direct_offset

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def make_direct_offset(offset, blk, pc, access=None):
    # if offset < 100000:
    #     print(offset)
    #     traceback.print_stack(file=sys.stdout)
    function = blk.function
    binary = function.binary

    if offset in binary.direct_offsets:
        direct_offset = binary.direct_offsets[offset]
    else:
        direct_offset = DirectOffset(binary=binary, offset=offset, access=access)
        binary.direct_offsets[offset] = direct_offset

    function.direct_offsets.add(offset)

    return direct_offset 
开发者ID:eth-sri,项目名称:debin,代码行数:18,代码来源:elmfactory.py

示例15: handleClientMessage_

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import print_stack [as 别名]
def handleClientMessage_(self, msg):
        if isinstance(msg, CumulusNative.ComputationResult):
            self.onComputationResult(msg.computation, msg.deserializedResult(self.vdm), msg.statistics)

        elif isinstance(msg, tuple):
            self.onCheckpointStatus(msg[0], msg[1])

        elif isinstance(msg, CumulusNative.VectorLoadedResponse):
            if not msg.loadSuccessful:
                traceback.print_stack()
                logging.info("MN>> Failure in handleClientMessage_: %s", traceback.format_exc())
                logging.critical("Page Load failed. This is not handled correctly yet. %s", msg)

            self.onCacheLoad(msg.vdid)
        elif isinstance(msg, CumulusNative.GlobalUserFacingLogMessage):
            self.onNewGlobalUserFacingLogMessage(msg)
        elif isinstance(msg, CumulusNative.ExternalIoTaskCompleted):
            self.onExternalIoTaskCompleted(msg) 
开发者ID:ufora,项目名称:ufora,代码行数:20,代码来源:CumulusGateway.py


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