-
Notifications
You must be signed in to change notification settings - Fork 191
Race condition failure when starting Debugger with python Gunicorn using virtual environment (venv) using VSCode & WSL #420
Copy link
Copy link
Closed
Description
Environment data
- VS Code version: 1.49.1
- Extension version (available under the Extensions sidebar): v2020.9.111407
- OS and version: Windows 10 Enterprise 1909
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.9
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
- Relevant/affected Python packages and their versions: N/A
- Relevant/affected Python-related VS Code extensions and their versions: N/A
- Value of the
python.languageServersetting: Mircrosoft
Expected behaviour
(.venv) gillani@NE023769:/mnt/c/git/queue-management$ cd /mnt/c/git/queue-management/api ; /usr/bin/env /mnt/c/git/queue-management/.venv/bin/python3 /home/gillani/.vscode-server/extensions/ms-python.python-2020.9.111407/pythonFiles/lib/python/debugpy/launcher 53426 -- /mnt/c/git/queue-management/.venv/bin/gunicorn wsgi --bind=0.0.0.0:5000 --access-logfile=- --config=/mnt/c/git/queue-management/api/gunicorn_config.py --timeout=9999
[2020-09-23 17:47:03 -0700] [17483] [INFO] Starting gunicorn 20.0.4
[2020-09-23 17:47:03 -0700] [17483] [INFO] Listening at: http://0.0.0.0:5000 (17483)
[2020-09-23 17:47:03 -0700] [17483] [INFO] Using worker: eventlet
[2020-09-23 17:47:04 -0700] [17498] [INFO] Booting worker with pid: 17498
==> SQLALCHEMY_ENGINE_OPTIONS (Engine: postgresql
{'max_overflow': 20, 'pool_pre_ping': False, 'pool_size': 10}
Actual behaviour
/usr/bin/env /mnt/c/git/queue-management/.venv/bin/python3 /home/gillani/.vscode-server/extensions/ms-python.python-2020.9.111407/pythonFiles/lib/python/debugpy/launcher 53413 -- /mnt/c/git/queue-management/.venv/bin/gunicorn wsgi --bind=0.0.0.0:5000 --access-logfile=- --config=/mnt/c/git/queue-management/api/gunicorn_config.py --timeout=9999
gillani@NE023769:/mnt/c/git/queue-management$ /usr/bin/env /mnt/c/git/queue-management/.venv/bin/python3 /home/gillani/.vscode-server/extensions/ms-python.python-2020.9.111407/pythonFiles/lib/python/debugpy/launcher 53413 -- /mnt/c/git/queue-management/.venv/bin/gunicorn wsgi --bind=0.0.0.0:5000 --access-logfile=- --config=/mnt/c/git/queue-management/api/gunicorn_config.py --timeout=9999
source /mnt/c/git/queue-management/.venv/bin/activate
[2020-09-23 17:46:21 -0700] [17438] [INFO] Starting gunicorn 20.0.4
[2020-09-23 17:46:21 -0700] [17438] [INFO] Listening at: http://0.0.0.0:5000 (17438)
[2020-09-23 17:46:21 -0700] [17438] [INFO] Using worker: eventlet
[2020-09-23 17:46:22 -0700] [17453] [INFO] Booting worker with pid: 17453
[2020-09-23 17:46:22 -0700] [17453] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/workers/geventlet.py", line 99, in init_process
super().init_process()
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/mnt/c/git/queue-management/.venv/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'wsgi'
[2020-09-23 17:46:22 -0700] [17453] [INFO] Worker exiting (pid: 17453)
[2020-09-23 17:46:22 -0700] [17438] [INFO] Shutting down: Master
[2020-09-23 17:46:22 -0700] [17438] [INFO] Reason: Worker failed to boot.
gillani@NE023769:/mnt/c/git/queue-management$ source /mnt/c/git/queue-management/.venv/bin/activate
(.venv) gillani@NE023769:/mnt/c/git/queue-management$
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
- Running WSL
- Add following in launch.json:
{
// This task runs the main API Python Gunicorn process.
"name": "Python: Gunicorn",
"type": "python",
"request": "launch",
// Change the `program` value to a path of your virtualenv's gunicorn file.
// This should be a path to the virtualenv used for project
// But instead of `env/bin/activate` we put `env/bin/gunicorn`
// e.g. when developing locally, I'd do `source queue-env/bin/activate`.
"program": "${workspaceFolder}/.venv/bin/gunicorn",
"gevent": true,
"cwd": "${workspaceFolder}/api",
// High timeout, so gunicorn won't kill process if we hit a debugging breakpoint
"args": ["wsgi", "--bind=0.0.0.0:5000", "--access-logfile=-", "--config=${workspaceFolder}/api/gunicorn_config.py", "--timeout=9999"],
},- Run Debugger to make fail
Note: Logs indicate missing packages, I suspect it fails because python virtual environment isn't set in time. - Run Debugger again and the gunicorn server starts with no issues.
Logs
N/A
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels