VScode remote debuger exits after change to django code?
I have configured vscode to debug my django application inside a docker container. It works well, but after I change my code, the debugger exits with the following message [error image] The exception message:
Exception has occurred: SystemExit (note: full exception trace is shown but execution is paused at: <module>)
3
File "/mnt/gb10/work_projects/albaraka/albaraka_backend/src/manage.py", line 28, in main
execute_from_command_line(sys.argv)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/mnt/gb10/work_projects/albaraka/albaraka_backend/src/manage.py", line 32, in <module> (Current frame)
main()
~~~~^^
SystemExit: 3
Here is my launch.json file
{
"configurations": [
{
"name": "Python Debugger: Remote Attach",
"type": "debugpy",
"request": "attach",
"connect": { "host": "0.0.0.0", "port": 8002 },
"pathMappings": [
{ "localRoot": "${workspaceFolder}/src", "remoteRoot": "/code" }
]
}
]
}
Here is my manage.py file
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'albserver.settings')
# Debugger
from django.conf import settings
if settings.DEBUG:
if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'):
import debugpy
debugpy.listen(("0.0.0.0", 8002))
print('Attached!')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
and docker-compose file
services:
alb-web:
container_name: alb-web
build: ./src
command: python -Xfrozen_modules=off manage.py runserver 0.0.0.0:8001
volumes:
- ./src/:/code
ports:
# Hp : Cp
- 8001:8001 # Main port
- 8002:8002 # Debugger Port
env_file:
- ./.env.dev
networks:
- alb_main_network
I tried to uncheck BREAKPOINTS > Uncaught Exceptions, but in this way the debugger exits silently.