Open jeffery9 opened 1 year ago
Probably related to #1206. Can you try using debugpy.breakpoint()
to trigger one manually and see if that works for you?
when workers
> 0 Odoo run in multi-process and multi-thread mode and with gevent patched too.
once turn off gevent=True
, debug in workers mode is ok, but raise error
It seems that the gevent monkey-patching is being used.
Please set an environment variable with:
GEVENT_SUPPORT=True
to enable gevent support in the debugger.
the working launch.json
{
"name": "Python: odoo-bin",
"type": "python",
"request": "launch",
"program": "odoo-bin",
"args": ["-c", "config/odoo.conf"],
"console": "integratedTerminal",
"justMyCode": false,
// "gevent": true,
"subProcess": true,
"cwd": "${workspaceFolder}"
},
and odoo.conf
[options]
addons_path = addons
admin_passwd = 1234
csv_internal_sep = ,
data_dir = /var/lib/odoo
db_host = db
db_maxconn = 64
db_name = False
db_password = odoo
db_port = 5432
db_sslmode = prefer
db_template = template0
db_user = odoo
dbfilter =
demo = {}
email_from = False
geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb
http_enable = True
http_interface =
http_port = 8069
import_partial =
limit_memory_hard = 2684354560
limit_memory_soft = 2147483648
limit_request = 8192
limit_time_cpu = 300
limit_time_real = 600
limit_time_real_cron = -1
list_db = True
log_db = False
log_db_level = warning
log_handler = :INFO
log_level = debug
logfile =
longpolling_port = 8072
max_cron_threads = 0
osv_memory_age_limit = False
osv_memory_count_limit = False
pg_path =
pidfile =
proxy_mode = True
reportgz = False
screencasts =
screenshots = /tmp/odoo_tests
server_wide_modules = base,web
smtp_password = False
smtp_port = 25
smtp_server = localhost
smtp_ssl = False
smtp_user = False
syslog = False
test_enable = False
test_file =
test_tags = None
transient_age_limit = 1.0
translate_modules = ['all']
unaccent = False
upgrade_path =
without_demo = False
workers = 2
there have another prolem: it is can't shudown debug process in one click.
It seems like Odoo is doing some unusual stuff, so we might have to add some specific support for it to make it work properly, on top of gevent support.
setup monkey patch as
# Is the server running with gevent.
evented = False
if len(sys.argv) > 1 and sys.argv[1] == 'gevent':
sys.argv.remove('gevent')
import gevent.monkey
import psycopg2
from gevent.socket import wait_read, wait_write
gevent.monkey.patch_all()
def gevent_wait_callback(conn, timeout=None):
"""A wait callback useful to allow gevent to work with Psycopg."""
# Copyright (C) 2010-2012 Daniele Varrazzo <daniele.varrazzo@gmail.com>
# This function is borrowed from psycogreen module which is licensed
# under the BSD license (see in odoo/debian/copyright)
while 1:
state = conn.poll()
if state == psycopg2.extensions.POLL_OK:
break
elif state == psycopg2.extensions.POLL_READ:
wait_read(conn.fileno(), timeout=timeout)
elif state == psycopg2.extensions.POLL_WRITE:
wait_write(conn.fileno(), timeout=timeout)
else:
raise psycopg2.OperationalError(
"Bad result from poll: %r" % state)
psycopg2.extensions.set_wait_callback(gevent_wait_callback)
evented = True
hope this should be helps.
thanks.
Any news about this ?
Still cannot debug Odoo with multiple workers even with gevent and subProcess set to true. It appears that the debugger is attaching to only one of the subprocesses (in my case the gevent / long polling process)
vscode version Version: 1.76.1 (Universal) Commit: 5e805b79fcb6ba4c2d23712967df89a089da575b Date: 2023-03-08T16:32:09.831Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Darwin x64 22.4.0 Sandboxed: No
run Odoo with workers in devcontainer
lanuch.json
asbreakpoint not worked,
but run Odoo with thread mode in devcontainer
lanuch.json
asbreakpoint worked,
ref. https://github.com/jeffery9/odoo-devcontainer
workers > 0 is workers mode. https://github.com/jeffery9/odoo-devcontainer/blob/3344530afa9685888b5b75b4594941fd0213c064/config/odoo.conf#L59