jiffyclub/snakeviz

'int' object is not iterable

tardyp opened this issue · 5 comments

Using snakeviz 0.4:

Traceback (most recent call last):
  File ".../site-packages/tornado/web.py", line 1413, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File ".../site-packages/snakeviz/main.py", line 30, in get
    table_rows=table_rows(s), callees=json_stats(s))
  File ".../site-packages/snakeviz/stats.py", line 65, in json_stats
    (keyfmt(*ck), list(cv)) for ck, cv in stats.stats[k][-1].items())
  File ".../site-packages/snakeviz/stats.py", line 65, in <genexpr>
    (keyfmt(*ck), list(cv)) for ck, cv in stats.stats[k][-1].items())
TypeError: 'int' object is not iterable

What version of Python are you on? Can you share the profile file with me?

I'm observing the same issue while I'm running snakeviz o.prof, where 'o.prof' is a (valid) profile, so the patch from #63 isn't really relevant. (github won't let me attach the profile, so unfortunately I can't share it here.)

I believe I have discovered the issue: There is a subtle difference between how the profile and the cProfile modules store caller information. The Stats.print_callers method documentation (https://docs.python.org/3/library/profile.html#the-stats-class) explains the difference. It would be great if snakeviz could support both.

Thanks for the clarification and link. At the moment SnakeViz only works with cProfile files because the profile module output doesn't seem to be sufficiently detailed to generate the visualization. I'd have to double check on that, though.

Do you know if there are situations in which the cProfile module is not available, or some other reason people use profile instead of cProfile?

I was actually experimenting with some extension (adding more information to function calls, such as argument types), which was easier to do with the profile module. But knowing that it provides less data than the cProfile module, I can certainly port my changes to that.

Thanks !