pythonprofilers / memory_profiler

Monitor Memory usage of Python code
http://pypi.python.org/pypi/memory_profiler
Other
4.39k stars 380 forks source link

Handle multiline command-line args #363

Open stepan-anokhin opened 2 years ago

stepan-anokhin commented 2 years ago

Fix the problem from #210

The problem occurs when mprof run <command> has multi-line arguments:

For example:

read -r -d '' MESSAGE << EOM            
  hello
  world
EOM

mprof run echo "$MESSAGE"
mprof plot
Using last profile data.
Traceback (most recent call last):
  File "/home/stepan/mprof-example/venv/bin/mprof", line 8, in <module>
    sys.exit(main())
  File "/home/stepan/mprof-example/venv/lib/python3.8/site-packages/mprof.py", line 905, in main
    actions[get_action()]()
  File "/home/stepan/mprof-example/venv/lib/python3.8/site-packages/mprof.py", line 819, in plot_action
    mprofile = plotter(filename, index=n, timestamps=timestamps, options=args)
  File "/home/stepan/mprof-example/venv/lib/python3.8/site-packages/mprof.py", line 409, in plot_file
    mprofile = read_mprofile_file(filename)
  File "/home/stepan/mprof-example/venv/lib/python3.8/site-packages/mprof.py", line 364, in read_mprofile_file
    field, value = l.split(' ', 1)
ValueError: not enough values to unpack (expected 2, got 1)