nvdv / vprof

Visual profiler for Python
BSD 2-Clause "Simplified" License
3.95k stars 154 forks source link

Profiling command-line based scripts that change terminal settings results in a termios error #112

Open lomnom opened 2 years ago

lomnom commented 2 years ago
Description

Profiling a CLI script results in this error:

Traceback (most recent call last):
  File "/usr/local/bin/vprof", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/vprof/__main__.py", line 83, in main
    program_stats = runner.run_profilers(source, config, verbose=True)
  File "/usr/local/lib/python3.9/site-packages/vprof/runner.py", line 73, in run_profilers
    run_stats[option] = curr_profiler.run()
  File "/usr/local/lib/python3.9/site-packages/vprof/base_profiler.py", line 172, in run
    return self.profile()
  File "/usr/local/lib/python3.9/site-packages/vprof/flame_graph.py", line 167, in profile_module
    return base_profiler.run_in_separate_process(self._profile_module)
  File "/usr/local/lib/python3.9/site-packages/vprof/base_profiler.py", line 79, in run_in_separate_process
    raise exc
termios.error: (19, 'Operation not supported by device')
How to reproduce

run vprof -c ch Test.py inside this folder.

Actual results

This happens after a while

Traceback (most recent call last):
  File "/usr/local/bin/vprof", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/vprof/__main__.py", line 83, in main
    program_stats = runner.run_profilers(source, config, verbose=True)
  File "/usr/local/lib/python3.9/site-packages/vprof/runner.py", line 73, in run_profilers
    run_stats[option] = curr_profiler.run()
  File "/usr/local/lib/python3.9/site-packages/vprof/base_profiler.py", line 172, in run
    return self.profile()
  File "/usr/local/lib/python3.9/site-packages/vprof/flame_graph.py", line 167, in profile_module
    return base_profiler.run_in_separate_process(self._profile_module)
  File "/usr/local/lib/python3.9/site-packages/vprof/base_profiler.py", line 79, in run_in_separate_process
    raise exc
termios.error: (19, 'Operation not supported by device')
Expected results

(without profiler)
Screenshot 2021-11-24 at 10 39 15 AM (side note: ctrl+z to quit Test.py)

Version and platform

vprof 0.38
MacOs 10.14.6
Screenshot 2021-11-24 at 10 41 48 AM