Tutorial: Attaching Visual Studio Code to Devstack LMS Container

@viadanna Thanks for this post. I got debugging working as you explain in those directions. Really appreciate it. Do you have any advice for PyCharm debugging with devstack_docker? Here is my progress on this.

One concern I had was that the /edx/app/edxapp/edx-platform/lms/env/private.py update of the following produced the following error when I did a make stop.all then make dev.up and Django never started until I commented out these lines.

import ptvsd
ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)

Error

WARNING:py.warnings:/edx/app/edxapp/edx-platform/lms/envs/private.py:9: DeprecationWarning: 'redirect_output' setting via enable_attach will be deprecated in the future versions of the debugger. This can be set using redirectOutput in Launch config in VS Code, using Tee output option in Visual Studio, or debugOptions configuration for any client.
  ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)

2020-07-07 21:57:27,956 WARNING 1101 [enterprise.utils] utils.py:50 - Could not import Registry from third_party_auth.provider
2020-07-07 21:57:27,957 WARNING 1101 [enterprise.utils] utils.py:51 - cannot import name _LTI_BACKENDS
Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/manage.py", line 123, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 61, in execute
    super(Command, self).execute(*args, **options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 100, in handle
    self.run(**options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in run
    autoreload.main(self.inner_run, None, options)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 341, in main
    reloader(wrapped_main_func, args, kwargs)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 312, in python_reloader
    exit_code = restart_with_reloader()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 298, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ)
  File "/usr/lib/python2.7/subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1235, in _execute_child
    self.pid = os.fork()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 528, in new_fork
    _on_forked_process()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 50, in _on_forked_process
    pydevd.settrace_forked()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_vendored/pydevd/pydevd.py", line 2427, in settrace_forked
    patch_multiprocessing=True,
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_vendored/pydevd/pydevd.py", line 2179, in settrace
    wait_for_ready_to_run,
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_vendored/pydevd/pydevd.py", line 2230, in _locked_settrace
    debugger.connect(host, port)  # Note: connect can raise error.
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_vendored/pydevd/pydevd.py", line 1060, in connect
    s = start_client(host, port)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/pydevd_hooks.py", line 136, in _start_client
    return start_client(daemon, h, p)
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_remote.py", line 62, in <lambda>
    start_client=(lambda daemon, h, port: start_daemon()),
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/_remote.py", line 50, in start_daemon
    _, next_session = daemon.start_server(addr=(host, port))
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/daemon.py", line 158, in start_server
    with self.started():
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/daemon.py", line 110, in started
    self.start()
  File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/ptvsd/daemon.py", line 145, in start
    raise RuntimeError('already started')
RuntimeError: already started