debugpy breaks packages using bgworker (multiprocessing)
Empirical observation suggests that additional processes spawned by debugpy
when debugging a package using multiprocessing
are not cleaned up correctly. This results in package reload / redeploy failing because the listening port is already taken. On surface the debugpy
package seems to support multiprocessing
(there's even a test!), but looks like our bgworker package has additional complications.
Not sure what the fix should be here, but at the very least there has to be a way to disable debugpy
(with an env var). I found it's possible to inject debugpy
into an already running process: https://github.com/microsoft/debugpy#attaching-to-a-running-process-by-id. If we can make this work, then the testenv-debug-*
targets can set that up at container runtime instead of us messing around with ncs-start-python-vm
at startup.