Why pdb.set_trace() doesn't work using bench?

I’m trying to use pdb to debug, but on terminal, I can’t use… show the pdb trace…but I can’t use them, appears to “block” the pdb trace…

17:05:08 web.1            | ipdb> > /Users/fellipeh/Developer/frappe/fellipeh-bench/apps/erpbr/erpbr/financeiro/doctype/caixa/caixa.py(25)get_saldo_anterior()
17:05:08 web.1            |      24     sql = "select COALESCE(c.saldo_inicial, 0) from `tabConta` c where (c.name = %s)"
17:05:08 web.1            | ---> 25     saldo_inicial = float(frappe.db.sql(sql, (conta))[0][0]) or 0
17:05:08 web.1            |      26
17:05:08 web.1            |
print sql
17:05:18 web.1            | ipdb> *** NameError: name 'sql' is not defined

I think, beause using bench with many others services, maybe make set_trace to stop working…

Any thoughts?

Regards,

Hi @fellipeh, I dont have troubles with pdb but all most of times, I’m calling it from the bench console using pdb.run("function()", locals())

Regarding the Web process, it don’t disable the tracing, and when the code enter there it block the requests.

The frappe-framework is not designed to hot tracing, but since you are using bench start you can edit the procfile, to enable the werkzeug debug mode.

2 Likes

hi @max_morais_dmm
when i enable werkzeug debug mode , what is the different ?
i try it the pdb.set_trace() works the same as expected for me in both cases ?

@ahmadRagheb this is how to debug the werkzeug mode

Also it’s accessible from the browser

http://werkzeug.pocoo.org/docs/0.14/debug/

Hi, I’m using bench and I don’t find a way to enable the werkzeug debug mode, can you give me a hand?

This is my Procfile

redis_cache: redis-server config/redis_cache.conf
redis_socketio: redis-server config/redis_socketio.conf
redis_queue: redis-server config/redis_queue.conf

web: bench serve --port 8000

socketio: /usr/bin/node apps/frappe/socketio.js

watch: bench watch

schedule: bench schedule
worker_short: bench worker --queue short 1>> logs/worker.log 2>> logs/worker.error.log
worker_long: bench worker --queue long 1>> logs/worker.log 2>> logs/worker.error.log
worker_default: bench worker --queue default 1>> logs/worker.log 2>> logs/worker.error.log

What suppose I need to do?
Thanks