nschloe / tuna

:fish: Python profile viewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to read prof file from WSGI Application Profiler

stephenrs opened this issue · comments

When I run "tuna <profile_output>.prof" I get the following:

Traceback (most recent call last):
  File "/Users/stephen/www/profiling/venv3/bin/tuna", line 11, in <module>
    sys.exit(main())
  File "/Users/stephen/www/profiling/venv3/lib/python3.6/site-packages/tuna/cli.py", line 33, in main
    start_server(args.infile, args.browser)
  File "/Users/stephen/www/profiling/venv3/lib/python3.6/site-packages/tuna/main.py", line 172, in start_server
    data = read(prof_filename)
  File "/Users/stephen/www/profiling/venv3/lib/python3.6/site-packages/tuna/main.py", line 33, in read
    return read_runtime_profile(filename)
  File "/Users/stephen/www/profiling/venv3/lib/python3.6/site-packages/tuna/main.py", line 37, in read_runtime_profile
    stats = pstats.Stats(prof_filename)
  File "/usr/local/Cellar/python/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pstats.py", line 72, in __init__
    self.init(arg)
  File "/usr/local/Cellar/python/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pstats.py", line 86, in init
    self.load_stats(arg)
  File "/usr/local/Cellar/python/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pstats.py", line 100, in load_stats
    self.stats = marshal.load(f)
ValueError: bad marshal data (unknown type code)

Also, the same files load fine in SnakeViz, but obviously I'm interested in the advanced features of Tuna.

Python v3.6.1
MacOS 10.13.5

Any suggestions would be greatly appreciated.

Actually, it looks like the problem is that I'm trying to read a prof file that was created from a python2.7 app/venv...but when I try to start Tuna in a Python2.7 venv I get the following error:

Traceback (most recent call last):
  File "/Users/stephen/www/wavebasis/venv/bin/tuna", line 7, in <module>
    from tuna.cli import main
  File "/Users/stephen/www/wavebasis/venv/lib/python2.7/site-packages/tuna/__init__.py", line 13, in <module>
    from . import cli
  File "/Users/stephen/www/wavebasis/venv/lib/python2.7/site-packages/tuna/cli.py", line 10, in <module>
    from .main import start_server, read, render
  File "/Users/stephen/www/wavebasis/venv/lib/python2.7/site-packages/tuna/main.py", line 3, in <module>
    from http.server import HTTPServer, BaseHTTPRequestHandler
ImportError: No module named server

Is there a way to get Tuna running in Py2.7, or is it Py3.x only?

Thanks

Well, looks like tuna needs Python 3. I wouldn't mind a PR that fixes it for Python 2 though. One probably needs SimpleHTTPServer for that.

Actually, considering the fact that Python 2 will be unsupported in a few months, let's not start supporting it now.

Python 2 profiles can be displayed with tuna nonetheless, of course.