You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before creating a new issue, please check the FAQ to see if your question is answered there.
Environment data
debugpy version: 1.8.0
OS and version: Ubuntu 22.0 LTS
Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
Using VS Code or Visual Studio: VS Code
Using cookiecutter-django for project setup
Actual behavior
Once the debugpy listen assigns the port, the runserver_plus autoloads and error message is shown regarding port already in use.
Expected behavior
Even if the server reloads debugpy should check if the port is already in use and if its in use by debugpy it should be able to be reused again so that the server does not crash.
Steps to reproduce:
Setup django project using cookiecutter-django using docker y as option
After project setup, inorder to attach debugger, modiy the manage.py file to include the following:
if os.environ.get("DEBUG"):
import debugpy
debugpy.listen(("0.0.0.0", 6087))
The runserver_plus command is executed from the /start script of the compose file for django.
On the first instance the port is assigned to debugpy but later the runserver_plus auto reloads and shows error of port already in use.
Setting runserver_plus with --no-reload arg is not the solution that I am looking for. Is there any other way this can be achieved?
Regards
The text was updated successfully, but these errors were encountered:
The port can't be reused because the parent process is still running, so connecting to that port would debug it. This would be better handled by only attaching the debugger to the child process - i.e. only doing listen() in the auto-reloaded process. Is that possible to detect?
The port can't be reused because the parent process is still running, so connecting to that port would debug it. This would be better handled by only attaching the debugger to the child process - i.e. only doing listen() in the auto-reloaded process. Is that possible to detect?
Thanks for the insight. I was able to connect the debugger with this workaround in my manage.py
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
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", 6087))
print("Debugger Listening!")
I tried by only doing listen() on the child process. It works but uncaught exceptions are raised. For now, the above code is working fine with my current project setup. And os.fork was not available in Windows causing doing listen() on child process to be platform specific. Thanks for the help.
Before creating a new issue, please check the FAQ to see if your question is answered there.
Environment data
Actual behavior
Once the debugpy listen assigns the port, the runserver_plus autoloads and error message is shown regarding port already in use.
Expected behavior
Even if the server reloads debugpy should check if the port is already in use and if its in use by debugpy it should be able to be reused again so that the server does not crash.
Steps to reproduce:
Setup django project using cookiecutter-django using docker y as option
After project setup, inorder to attach debugger, modiy the manage.py file to include the following:
if os.environ.get("DEBUG"):
import debugpy
debugpy.listen(("0.0.0.0", 6087))
The runserver_plus command is executed from the /start script of the compose file for django.
On the first instance the port is assigned to debugpy but later the runserver_plus auto reloads and shows error of port already in use.
Setting runserver_plus with --no-reload arg is not the solution that I am looking for. Is there any other way this can be achieved?
Regards
The text was updated successfully, but these errors were encountered: