☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

A (maybe) helpful tip on debugging "bokeh serve"

Community Support
Colin
Colin

I was quite frustrated debugging my callbacks mainly because I saw only the error message but python didn’t tell me in which line the exception occurred.
There might be an easier way but I found a workaround. Wrap your callback in a try-catch-block like this:

def my_callback():
    try:
        ...normal code...
    except Exception as e:
        import traceback
        traceback.print_exc()
        raise e

In this way, the stack trace will be printed and the exception is forwarded as usual. Hope it helps somebody.

⌁   Link to post
kevindesimone
kevindesimone

Very nice.

···

On Wednesday, August 30, 2017 at 7:52:32 AM UTC-4, Colin wrote:

I was quite frustrated debugging my callbacks mainly because I saw only the error message but python didn’t tell me in which line the exception occurred.
There might be an easier way but I found a workaround. Wrap your callback in a try-catch-block like this:

def my_callback():
    try:
        ...normal code...
    except Exception as e:
        import traceback
        traceback.print_exc()
        raise e

In this way, the stack trace will be printed and the exception is forwarded as usual. Hope it helps somebody.

⌁   Link to post
Bryan
Bryan

Perhaps we could add something like that built in. In general, putting things in try/except blocks will incur performance overhead, so I would not want to have it on by default, but it might make sense as an optional debugging more. Please feel free to open a GH issue to discuss.

Thanks,

Bryan

···

On Aug 30, 2017, at 09:33, kevindesimone@gmail.com wrote:

Very nice.

On Wednesday, August 30, 2017 at 7:52:32 AM UTC-4, Colin wrote:
I was quite frustrated debugging my callbacks mainly because I saw only the error message but python didn't tell me in which line the exception occurred.
There might be an easier way but I found a workaround. Wrap your callback in a try-catch-block like this:

def my_callback():
    try:
        ...normal code...
    except Exception as e:
        import traceback
        traceback.print_exc()
        raise e

In this way, the stack trace will be printed and the exception is forwarded as usual. Hope it helps somebody.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0fd4cc78-4e0c-4c58-89f8-95313e94c8d5%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled