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

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.

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.

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, [email protected] 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 [email protected].
To post to this group, send email to [email protected].
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\.