概述
如果def do_event_in(self, buf):
s = traceback.extract_stack()
print '%s Invoked me!'%s[-2][2]
log_debug('server in %s' % buf)
buf.clear()
self.push()
return 0没有import traceback
运行结果将显示:NameError: global name 'traceback' is not defined。Python首先在函数f的本地作用域中查找 traceback,查找失败,接着在全局作用域和内置作用域中查找变量i,仍然失败,最终抛出NameError异常。
Traceback (most recent call last):
File "./tcp_server.py", line 139, in <module>
unit.start()
File "/data/dreamliang/mySvn/sdn_proj/branches/oss/common/poller_timer_unit.py", line 23, in start
CPollerUnit.process_poller_events(self)
File "/data/dreamliang/mySvn/sdn_proj/branches/oss/common/poller.py", line 207, in process_poller_events
if epoll_object.input_notify() >= 0:
File "./tcp_server.py", line 95, in input_notify
ret = server_conn_object.init(server_conn, self)
File "./tcp_server.py", line 29, in init
return self.push()
File "/data/dreamliang/mySvn/sdn_proj/branches/oss/common/tcp_base_connect.py", line 42, in push
if self._conn is None: ret = self.create_conn()
File "./tcp_server.py", line 38, in create_conn
if not self.b_use_oob(): self.input_notify()
File "./tcp_server.py", line 42, in input_notify
return CTcpBaseConnect.input_notify(self)
File "/data/dreamliang/mySvn/sdn_proj/branches/oss/common/tcp_base_connect.py", line 143, in input_notify
return self.do_event_in()
File "/data/dreamliang/mySvn/sdn_proj/branches/oss/common/tcp_base_connect.py", line 121, in do_event_in
ret = self.handle_event_in()
File "/data/dreamliang/mySvn/sdn_proj/branches/oss/common/tcp_base_connect.py", line 111, in handle_event_in
ret = self._handle.do_event_in(self._in_buf)
File "/data/dreamliang/mySvn/sdn_proj/branches/oss/common/tcp_handle.py", line 136, in do_event_in
s = traceback.extract_stack()
NameError: global name 'traceback' is not defined
最后
以上就是纯真画板为你收集整理的抛异常找程序执行流程的全部内容,希望文章能够帮你解决抛异常找程序执行流程所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复