florianschanda / miss_hit

MATLAB Independent, Small & Safe, High Integrity Tools - code formatter and more
GNU General Public License v3.0
158 stars 21 forks source link

`--debug-dump-tree` throws uncaught `TypeError` #282

Open mitiemann opened 8 months ago

mitiemann commented 8 months ago

MISS_HIT Component affected

Your MATLAB/Octave environment none (should not be required)

Your operating system and Python version

Describe the bug When trying to enable the --debug-dump-tree option, the call fails with an uncaugt TypeError. E.g. python miss_hit_core/mh_style.py --debug-dump-error output.txt miss_hit.m produces

Traceback (most recent call last):
  File "/home/mtiemann/dev/miss_hit/miss_hit_core/mh_style.py", line 1301, in <module>
    main()
  File "/home/mtiemann/dev/miss_hit/miss_hit_core/mh_style.py", line 1297, in main
    command_line.ice_handler(main_handler)
  File "/home/mtiemann/dev/miss_hit/miss_hit_core/command_line.py", line 448, in ice_handler
    main_function()
  File "/home/mtiemann/dev/miss_hit/miss_hit_core/mh_style.py", line 1288, in main_handler
    command_line.execute(mh, options, extra_options,
  File "/home/mtiemann/dev/miss_hit/miss_hit_core/command_line.py", line 432, in execute
    for results in pool.imap(process_fn, work_list, 5):
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 423, in <genexpr>
    return (item for chunk in result for item in chunk)
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next
    raise value
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 540, in _handle_tasks
    put(task)
  File "/usr/lib/python3.10/multiprocessing/connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/usr/lib/python3.10/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
TypeError: cannot pickle '_io.TextIOWrapper' object

Edit: Everything works when disabling multi-threading with the --single option. Since this creates a viable workaround, I'm wondering whether requesting --debug-dump-tree should simply lead to disabling multi-threading by default and call it a day?

florianschanda commented 7 months ago

That might be a good idea. I am not sure why the two options should interfere though, could be a latent bug. I'll look into it.