tracing.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:nodepy 作者: nodepy 项目源码 文件源码
def format_html(fp, exclude=()):
  frames = stackframes()
  fp.write('<!DOCTYPE html>\n')
  fp.write('<html><head><title>{} Traces</title></head><body>\n'.format(len(frames)))
  for thread_id, stack in sorted(frames.items(), key=lambda x: x[0]):
    name = 'Thread {}'.format(thread_id)
    if thread_id == threading.get_ident():
      name += ' (tracing thread)'
    elif thread_id == main_thread.ident:
      name += ' (main)'
    fp.write('<h3>{}</h3>\n'.format(name))
    tbstr = format_stack(stack)
    if pygments:
      formatter = pygments.formatters.HtmlFormatter(full=False, noclasses=True)
      lexer = pygments.lexers.PythonLexer()
      tbstr = pygments.highlight(tbstr, lexer, formatter)
    fp.write(tbstr)
    fp.write('\n')
  fp.write('</body>\n')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号