reloadium icon indicating copy to clipboard operation
reloadium copied to clipboard

multiprocessing processes fail to launch when debug is started with Reloadium

Open llucid-97 opened this issue 3 years ago • 1 comments

Describe the bug

I have functions I want to launch in parallel using python's multiprocessing. I want to be able to set breakpoints inside these parallel processes like I can with the normal debugger and hot reload modifications of my code in them.

To Reproduce I have created this minimum example to showcase the error:

import time
import multiprocessing as mp

def foo(i,_lock):
    print(f"Running Foo[{i}]")
    time.sleep(2)
    with _lock:
        print(f"finished Foo[{i}]")


def main(number_of_parallel_processes):
    ps = []
    _lock = mp.Lock()
    print("main is ready to launch")
    for i in range(number_of_parallel_processes):
        p = mp.Process(target=foo,args=(i,_lock))
        p.start()
        ps.append(p)

    [p.join() for p in ps]

if __name__ == '__main__':
    mp.set_start_method('spawn',force=True)
    main(number_of_parallel_processes=2)

When I run this with reloadium's debug (orange Debug icon), it crashes when trying to launch the processes:

D:\Users\agimg\Miniconda3\envs\clockwork_mind\python.exe -m reloadium pydev_proxy "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev\pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 51971 --file D:/projects/fastpbrl-main/scripts/scratchpads/hot_reload_multiproc.py Connected to pydev debugger (build 221.5080.212) ■■■■■■■■■■■■■■■ Reloadium 0.9.2 ■■■■■■■■■■■■■■■ If you like this project consider becoming a sponsor or giving a star at https://github.com/reloadware/reloadium main is ready to launch Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_monkey.py", line 197, in patch_args host, port = _get_host_port() File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_monkey.py", line 47, in _get_host_port host, port = pydevd.dispatch() File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1875, in dispatch host = setup['client'] TypeError: 'NoneType' object is not subscriptable Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_monkey.py", line 197, in patch_args host, port = _get_host_port() File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_monkey.py", line 47, in _get_host_port host, port = pydevd.dispatch() File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev\pydevd.py", line 1875, in dispatch host = setup['client'] TypeError: 'NoneType' object is not subscriptable File "", line 1 from ^ SyntaxError: invalid syntax File "", line 1 from ^ SyntaxError: invalid syntax

Process finished with exit code 0

Expected behavior When I run this with the normal pycharm debugger (pressing the green Debug icon), I get the expected output:

D:\Users\agimg\Miniconda3\envs\clockwork_mind\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2022.1\plugins\python-ce\helpers\pydev\pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 51960 --file D:/projects/fastpbrl-main/scripts/scratchpads/hot_reload_multiproc.py Connected to pydev debugger (build 221.5080.212) main is ready to launch Running Foo[1] Running Foo[0] finished Foo[0] finished Foo[1]

Process finished with exit code 0

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • OS version: 10
  • Reloadium package version: ~~0.8.5~~ 0.9.2 (*edit: thought this was same as pycharm plugin version.)
  • PyCharm plugin version: 0.8.5
  • Editor: Pycharm 2022.1
  • Run mode: Debug

Additional context Using Python 3.10.2

llucid-97 avatar Sep 08 '22 14:09 llucid-97

happens to me as well

  • OS: Linux ubuntu
  • OS version: 18.04
  • Reloadium package version: 0.9.2
  • PyCharm plugin version: 0.8.5
  • Editor: Pycharm 2022.1
  • Run mode: Debug Additional context Using python 3.7.8

adoxentor avatar Sep 19 '22 10:09 adoxentor

Fixed in reloadium 0.9.3 and PyCharm plugin 0.8.6

dkrystki avatar Oct 07 '22 05:10 dkrystki