Bokeh Server doesn't run my main function

I’ve got this at the end of my script:
if name == ‘main’:

main()

Why doesn’t Bokeh Server run the stuff inside my defined main function? Thanks.

Hi,

The Bokeh server is a bit like the Jupyter notebook server. It's a program that runs other python code in a special way, in order to add some capabilities. Although we have tried to make things behave like "normal python" in order to minimize surprises, the fact is that running "bokeh server foo.py" is *not* identical to running "python foo.py".

I supposed it's possible we could explicitly instrument scripts we execute by setting __name__ by hand before executing them. But this would need some discussion and investigation, to make sure there are not any unintended consequences. (Or maybe it would need to be configurable). Feel free to open a GH issue about it.

In the mean time, I'd just say, this sort of thing is just not the way to write a bokeh app script, and that have it function you'll need to call main() at the bottom unconditionally.

Thanks,

Bryan

···

On Mar 24, 2017, at 12:30, Tommy Carstensen <[email protected]> wrote:

I've got this at the end of my script:
if __name__ == '__main__':
    main()

Why doesn't Bokeh Server run the stuff inside my defined main function? Thanks.

--
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/85b590bc-ed0e-4a87-bcea-b08492cb55d3%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Bryan. I fixed it already. It was just unexpected behaviour. I just got my very first Bokeh Serve® plot to work. I’m well excited. Thanks!

···

On Fri, 24 Mar 2017 at 17:45 Bryan Van de ven [email protected] wrote:

Hi,

The Bokeh server is a bit like the Jupyter notebook server. It’s a program that runs other python code in a special way, in order to add some capabilities. Although we have tried to make things behave like “normal python” in order to minimize surprises, the fact is that running “bokeh server foo.py” is not identical to running “python foo.py”.

I supposed it’s possible we could explicitly instrument scripts we execute by setting name by hand before executing them. But this would need some discussion and investigation, to make sure there are not any unintended consequences. (Or maybe it would need to be configurable). Feel free to open a GH issue about it.

In the mean time, I’d just say, this sort of thing is just not the way to write a bokeh app script, and that have it function you’ll need to call main() at the bottom unconditionally.

Thanks,

Bryan

On Mar 24, 2017, at 12:30, Tommy Carstensen [email protected] wrote:

I’ve got this at the end of my script:

if name == ‘main’:

main()

Why doesn’t Bokeh Server run the stuff inside my defined main function? Thanks.

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/85b590bc-ed0e-4a87-bcea-b08492cb55d3%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to a topic in the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/G9Sy7XFGQWQ/unsubscribe.

To unsubscribe from this group and all its topics, 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/3218F7ED-5CA7-4F6F-BDEC-FED115B00EA9%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.