-
Notifications
You must be signed in to change notification settings - Fork 137
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
Debugger with gevent doesn't hit breakpoints #1206
Comments
Actually running the web app without the gevent support from VS Code logs the following warning but the debugger works as expected. It seems that the gevent monkey-patching is being used. |
To clarify, by gevent support from VSCode, do you mean |
One thing of note is that Odoo itself has some kind of integrated profiling functionality - it calls It's not clear to me whether this is conditional or not, but if it runs in your repro, it would effectively override the debugger. If so, I would expect |
Yes, I mean "gevent": true inside the config. I'll try what You asked as soon as possible. |
This is what I tried so far: The function debugpy.breakpoint() works like the IDE (without the gevent: true option stops the execution but I get warnings, with the option enabled I get no warning but it doesn't work at all. I also tried to comment the lines inside the profiler and there is no difference at all. |
Ok I think this is the problem. I don't know if this is the normal behavior but a solution would be an option to disable the warning about gevent being used. |
What's weird is that enabling gevent support makes breakpoints not work for you in the process that doesn't use it (if I understand correctly). For the warning, I think we'd want to disable it if you explicitly set |
Yes, this is the weird part. Maybe it's a problem in the way the framework spawns the processes or uses gevent, idk. I have also tried to comment the part where the gevent process starts and the warning is gone so it seems that the problem is actually when both sub-process kinds coexist. The option to disable the warning can be useful for now (for me it's not an issue because I don't need to debug the gevent part at the moment) but it can be also useful to make it work with both parts. If you need other test cases just tell me. |
yes. Odoo spawns the long polling process with gevent patched.
|
This workaround did the trick for me. I'm able to use the VsCode debugger while supressing I had to overwrite Odoo's entrypoint and set the #!/usr/bin/python3
# enable gevent support in the debugger
__import__('os').environ['GEVENT_SUPPORT'] = 'true'
# set server timezone in UTC before time module imported
__import__('os').environ['TZ'] = 'UTC'
import odoo
if __name__ == "__main__":
odoo.cli.main() |
Can confirm this works. Thank you @Pexers |
For reference, in case it helps someone. I want to use the upstream version of Odoo and avoid conflicts (in this case with odoo-bin). In my setup I have odoo/odoo in a folder named framework, therefore my project stands as:
Based on the solution from @Pexers I have a new file
and I have this launch.json file for VSCode:
With this I can use the debugger, use workers in Odoo and avoid issues with upstream. |
Thank you for the report. Given our current resources are working on the Python 3.12 debugger, we will not be fixing this issues in the pre Python 3.12 debugger. |
@judej So this issue gets considered in 3.12 or not? Sorry to ask but your statement was not clear on this and I get the impression it will just be ignored. It is a fair thing to ignore it, I would just like to know so that I can manage my expectations. |
Doesn't work if just set environment variables inside launch.json ? {
"version": "0.2.0",
"configurations": [
{
"name": "Odoo",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/odoo/odoo-bin",
"args": [
"--config=conf/odoo-server.conf",
"--dev=xml,qweb"
],
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"justMyCode": false,
"subProcess": true,
"gevent": true,
"env": {
"GEVENT_SUPPORT": "true",
"PYTEST_ADDOPTS": "--no-cov"
}
}
]
} But even so, my debugger is still attached to only one of the subprocesses (gevent / lonpoling) and not the main ones ... |
This is still an issue including latest versions and python 3.12 so @jpoa I suspect you were correct that it's being ignored. Such a shame because I have enjoyed this editor but I think it's time to move along to something that will work for our needs. |
Not sure why this was closed, but I think the thought was that 3.12 would just make this work because 3.12 doesn't use sys.trace anymore. Sounds like it didn't though. |
Environment data
Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Date: 2023-01-09T16:57:40.428Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 5.15.0-58-generic
Sandboxed: No
Actual behavior
When Gevent support is enabled the debugger doesn't hit the breakpoints. Without Gevent and the framework (Odoo) default threaded mode debugger works fine.
Expected behavior
Debugger should hit the breakpoints.
Steps to reproduce:
The text was updated successfully, but these errors were encountered: