Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to debug Python project on Linux #2051

Closed
v-mengwe opened this issue Jun 9, 2020 · 5 comments
Closed

Fail to debug Python project on Linux #2051

v-mengwe opened this issue Jun 9, 2020 · 5 comments
Assignees
Milestone

Comments

@v-mengwe
Copy link

v-mengwe commented Jun 9, 2020

OS: Linux
Build Version: 20200608.5

Repro Steps:

  1. Open a Python project(Django/Flask) in VS Code.
  2. F1 -> Docker: Add Docker Files to Workspace -> Python ->include docker compose files.
  3. F5.

Expect:
Debug Python project successfully without any error.

Actual:
Fail to debug Python project.
timeout

More Info:
This issue does not reproduce on Windows and Mac.

@v-mengwe v-mengwe added the AT-CTI label Jun 9, 2020
@v-mengwe v-mengwe changed the title Fail to debug Python project Fail to debug Python project on Linux Jun 9, 2020
@bwateratmsft bwateratmsft added this to the 1.3.0 milestone Jun 9, 2020
@haniamr
Copy link
Contributor

haniamr commented Jun 9, 2020

@v-mengwe I'm unable to repro this exact issue, however, for Flask apps I do get the same error as in this issue: #2048.

What app are you using here and can you share the output from "Docker" and "Python" terminals?
Also is that due to modifying any networking settings for the container?

@v-mengwe
Copy link
Author

@haniamr Thanks for your sharing.
Verified on the latest build 20200609.5, this issue still reproduces. I am using the following apps:

Output logs:
"Docker" terminals:

Executing task: docker-build <

docker build --rm --pull -f "/home/serene/Downloads/python-sample-vscode-django-tutorial-tutorial/Dockerfile" --label "com.microsoft.created-by=visual-studio-code" -t "pythonsamplevscodedjangotutorialtutorial:latest" "/home/serene/Downloads/python-sample-vscode-django-tutorial-tutorial" <

Sending build context to Docker daemon 175.1kB
Step 1/12 : FROM python:3.8-slim-buster
3.8-slim-buster: Pulling from library/python
8559a31e96f4: Pulling fs layer
62e60f3ef11e: Pulling fs layer
93c8ae153782: Pulling fs layer
ea222f757df7: Pulling fs layer
e97d3933bbbe: Pulling fs layer
ea222f757df7: Waiting
e97d3933bbbe: Waiting
62e60f3ef11e: Verifying Checksum
62e60f3ef11e: Download complete
ea222f757df7: Verifying Checksum
ea222f757df7: Download complete
e97d3933bbbe: Verifying Checksum
e97d3933bbbe: Download complete
8559a31e96f4: Verifying Checksum
8559a31e96f4: Download complete
8559a31e96f4: Pull complete
62e60f3ef11e: Pull complete
93c8ae153782: Verifying Checksum
93c8ae153782: Download complete
93c8ae153782: Pull complete
ea222f757df7: Pull complete
e97d3933bbbe: Pull complete
Digest: sha256:938fd520a888e9dbac3de374b8ba495cc50fe96440030264a40f733052001895
Status: Downloaded newer image for python:3.8-slim-buster
---> 9d84edf35a0a
Step 2/12 : EXPOSE 8000
---> Running in 2b1d3b6caf70
Removing intermediate container 2b1d3b6caf70
---> a8a61234f693
Step 3/12 : ENV PYTHONDONTWRITEBYTECODE 1
---> Running in 2ae9ed978177
Removing intermediate container 2ae9ed978177
---> 7c7c72854e98
Step 4/12 : ENV PYTHONUNBUFFERED 1
---> Running in 63a8d5c666aa
Removing intermediate container 63a8d5c666aa
---> c59843e7a59e
Step 5/12 : ADD requirements.txt .
---> b33a94036121
Step 6/12 : RUN python -m pip install -r requirements.txt
---> Running in b98bfa542add
Collecting django==3.0.3
Downloading Django-3.0.3-py3-none-any.whl (7.5 MB)
Collecting gunicorn==20.0.4
Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
Collecting asgiref~=3.2
Downloading asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
Collecting pytz
Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
Requirement already satisfied: setuptools>=3.0 in /usr/local/lib/python3.8/site-packages (from gunicorn==20.0.4->-r requirements.txt (line 3)) (47.1.1)
Installing collected packages: asgiref, sqlparse, pytz, django, gunicorn
Successfully installed asgiref-3.2.7 django-3.0.3 gunicorn-20.0.4 pytz-2020.1 sqlparse-0.3.1
Removing intermediate container b98bfa542add
---> d8e42dec362b
Step 7/12 : WORKDIR /app
---> Running in 8792e7122e72
Removing intermediate container 8792e7122e72
---> 8aa0ad5555db
Step 8/12 : ADD . /app
---> 532375700579
Step 9/12 : RUN useradd appuser && chown -R appuser /app
---> Running in 787e960c7fcf
Removing intermediate container 787e960c7fcf
---> ec803ab093be
Step 10/12 : USER appuser
---> Running in f47522f077db
Removing intermediate container f47522f077db
---> 45ca7aaacaed
Step 11/12 : CMD ["gunicorn", "--bind", "0.0.0.0:8000", "pythonPath.to.wsgi"]
---> Running in 0f17b93f74b9
Removing intermediate container 0f17b93f74b9
---> 66084c1ca8cd
Step 12/12 : LABEL com.microsoft.created-by=visual-studio-code
---> Running in 572ba3c87859
Removing intermediate container 572ba3c87859
---> d12cb3768345
Successfully built d12cb3768345
Successfully tagged pythonsamplevscodedjangotutorialtutorial:latest

Terminal will be reused by tasks, press any key to close it.

Executing task: docker-run: debug <

docker run -dt -P --name "pythonsamplevscodedjangotutorialtutorial-dev" --label "com.microsoft.created-by=visual-studio-code" -v "/home/serene/.vscode/extensions/ms-python.python-2020.5.86398/pythonFiles/lib/python/debugpy/no_wheels:/pydbg:ro" --entrypoint "python" "pythonsamplevscodedjangotutorialtutorial:latest" <

c8625dc8498cbf1df1ab714ed509df46b21244f84166abdb4e6466b4235b74d8

Terminal will be reused by tasks, press any key to close it.

"Python" terminals:

serene@serene:~$ env /usr/bin/python3 /home/serene/.vscode/extensions/ms-azuretools.vscode-docker-1.3.0/resources/python/launcher.py 0.0.0.0:44737 -- manage.py runserver 0.0.0.0:8000 --nothreading --noreload pythonsamplevscodedjangotutorialtutorial-dev
docker exec -d pythonsamplevscodedjangotutorialtutorial-dev python /pydbg/debugpy/launcher 0.0.0.0:44737 -- manage.py runserver 0.0.0.0:8000 --nothreading --noreload

@haniamr
Copy link
Contributor

haniamr commented Jun 10, 2020

After doing some investigation, turns out for some reason the "bridge" network does not have a "gateway" property, and we expect to find that so the launcher can connect back to VSCode.

The workaround is to restart Docker:

sudo systemctl daemon-reload
sudo systemctl stop docker
sudo systemctl start docker

Here is a link to the related issue in Docker's repo: moby/moby#26799

@bwateratmsft
Copy link
Contributor

bwateratmsft commented Jun 10, 2020

@haniamr Thanks for investigating! I guess we can resolve this one as external? Unless there's something reasonable we can do as a workaround.

@haniamr
Copy link
Contributor

haniamr commented Jun 10, 2020

@bwateratmsft sure thing. I guess we can resolve it as external, there isn't any workaround that I can think of apart of restarting the daemon as mentioned above.

@haniamr haniamr closed this as completed Jun 10, 2020
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants