Django embedded bokeh, multiple users 1 server live plots

Hello

I’ve been at this for a couple of weeks now, and I can’t seem to figure it out, however, I feel like I’m really close.

I’ve tried alot of things, but I was able to simplify it to these 2 code snippets.

Here is a code snippet of the file I run with bokeh serve:

curdoc().add_root(fig)

curdoc().add_periodic_callback(…,100)

In my views.py in Django, I do the following (code snippet):

def index(request):

session = pull_session(url = …)

script = server_session(None, session_id = session.id, url = …)

return render(request, …, context = {‘script’ : script})

This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).

However, I cannot get multiple users see this plot. “Model must be owned by single document”

After researching, I found a post about this exact problem. I had to add the following in my view:

def index(request):

session = pull_session(url = …)

session.document.roots[0].title.text = “Plot”

session.push()

script = server_session(None, session_id = session.id, url = …)

return render(request, …, context = {‘script’ : script})

I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I’m not sure about this.

Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn’t get streamed anymore.

Could anyone help me with this problem?

Thank you in advance

Hi,

I think you are running into this:

  https://github.com/bokeh/bokeh/issues/7724

As described there, you can try explicitly calling "session.close()" in your current code. In the next release, there is a new context manager that should be used that takes care of this:

  https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client

For now, you could also try this new context manager out by installing a "dev build"

Thanks,

Bryan

···

On May 3, 2018, at 12:55, Arthur <[email protected]> wrote:

Hello

I've been at this for a couple of weeks now, and I can't seem to figure it out, however, I feel like I'm really close.
I've tried alot of things, but I was able to simplify it to these 2 code snippets.

Here is a code snippet of the file I run with bokeh serve:
    curdoc().add_root(fig)
    curdoc().add_periodic_callback(...,100)

In my views.py in Django, I do the following (code snippet):

def index(request):
    session = pull_session(url = ...)
    script = server_session(None, session_id = session.id, url = ...)
    return render(request, ..., context = {'script' : script})

This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).

However, I cannot get multiple users see this plot. "Model must be owned by single document"

After researching, I found a post about this exact problem. I had to add the following in my view:

def index(request):
    session = pull_session(url = ...)
    session.document.roots[0].title.text = "Plot"
    session.push()
    script = server_session(None, session_id = session.id, url = ...)
    return render(request, ..., context = {'script' : script})

I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I'm not sure about this.

Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn't get streamed anymore.

Could anyone help me with this problem?

Thank you in advance

--
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/8e3750b6-0ef3-4b82-910c-0ea68d66f639%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hello Bryan

Thank you so much for answering. I was under the impression a session needed to be open as long as the browser is on that page.

I have removed the following lines:

session.document.roots[0].title.text = “Plot”

session.push()

so that the plots get updated again and have added:

session.close()

as suggested in issue 7724.

However, I still get the same error: Model must be owned by a single doc. Rendering a keyerror in my browser. Which I find odd, as the sessions get closed.

Thanks,

Arthur

···

Op donderdag 3 mei 2018 20:15:24 UTC+2 schreef Bryan Van de ven:

Hi,

I think you are running into this:

    [https://github.com/bokeh/bokeh/issues/7724](https://github.com/bokeh/bokeh/issues/7724)

As described there, you can try explicitly calling “session.close()” in your current code. In the next release, there is a new context manager that should be used that takes care of this:

    [https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client](https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client)

For now, you could also try this new context manager out by installing a “dev build”

Thanks,

Bryan

On May 3, 2018, at 12:55, Arthur [email protected] wrote:

Hello

I’ve been at this for a couple of weeks now, and I can’t seem to figure it out, however, I feel like I’m really close.

I’ve tried alot of things, but I was able to simplify it to these 2 code snippets.

Here is a code snippet of the file I run with bokeh serve:

curdoc().add_root(fig)
curdoc().add_periodic_callback(...,100)

In my views.py in Django, I do the following (code snippet):

def index(request):

session = pull_session(url = ...)
script = server_session(None, session_id = [session.id](http://session.id), url = ...)
return render(request,  ..., context = {'script' : script})

This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).

However, I cannot get multiple users see this plot. “Model must be owned by single document”

After researching, I found a post about this exact problem. I had to add the following in my view:

def index(request):

session = pull_session(url = ...)
session.document.roots[0].title.text = "Plot"
session.push()
script = server_session(None, session_id = [session.id](http://session.id), url = ...)
return render(request,  ..., context = {'script' : script})

I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I’m not sure about this.

Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn’t get streamed anymore.

Could anyone help me with this problem?

Thank you in advance


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/8e3750b6-0ef3-4b82-910c-0ea68d66f639%40continuum.io.

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

In that case I suspect the issue is actually in the file you run with "bokeh serve". That message indicates that some Bokeh model is getting created once, is is trying to be used for multiple sessions. This could happen e.g. if you define a Bokeh model as a top level module-variable in some separate module that you import. Because python caches module imports, only one Bokeh model gets created, and then reused for every connection. But Bokeh models cannot be re-used between connections. A solution might be to have the separate module define functions that create and return the Bokeh models, then the main app script can call the function to get brand new instances on every connection. This is just one possible scenario, but that is definitely ultimately what is happening based on the error message.

Thanks,

Bryan

···

On May 3, 2018, at 13:37, Arthur <[email protected]> wrote:

Hello Bryan

Thank you so much for answering. I was under the impression a session needed to be open as long as the browser is on that page.
I have removed the following lines:
    session.document.roots[0].title.text = "Plot"
    session.push()
so that the plots get updated again and have added:
    session.close()
as suggested in issue 7724.

However, I still get the same error: Model must be owned by a single doc. Rendering a keyerror in my browser. Which I find odd, as the sessions get closed.

Thanks,

Arthur

Op donderdag 3 mei 2018 20:15:24 UTC+2 schreef Bryan Van de ven:
Hi,

I think you are running into this:

        https://github.com/bokeh/bokeh/issues/7724

As described there, you can try explicitly calling "session.close()" in your current code. In the next release, there is a new context manager that should be used that takes care of this:

        https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client

For now, you could also try this new context manager out by installing a "dev build"

Thanks,

Bryan

> On May 3, 2018, at 12:55, Arthur <[email protected]> wrote:
>
> Hello
>
> I've been at this for a couple of weeks now, and I can't seem to figure it out, however, I feel like I'm really close.
> I've tried alot of things, but I was able to simplify it to these 2 code snippets.
>
>
> Here is a code snippet of the file I run with bokeh serve:
> curdoc().add_root(fig)
> curdoc().add_periodic_callback(...,100)
>
> In my views.py in Django, I do the following (code snippet):
>
> def index(request):
> session = pull_session(url = ...)
> script = server_session(None, session_id = session.id, url = ...)
> return render(request, ..., context = {'script' : script})
>
> This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).
>
> However, I cannot get multiple users see this plot. "Model must be owned by single document"
>
> After researching, I found a post about this exact problem. I had to add the following in my view:
>
> def index(request):
> session = pull_session(url = ...)
> session.document.roots[0].title.text = "Plot"
> session.push()
> script = server_session(None, session_id = session.id, url = ...)
> return render(request, ..., context = {'script' : script})
>
> I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I'm not sure about this.
>
> Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn't get streamed anymore.
>
>
> Could anyone help me with this problem?
>
> Thank you in advance
>
> --
> 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/8e3750b6-0ef3-4b82-910c-0ea68d66f639%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/e9b8842c-66e9-41f2-a04f-98bbf050bb05%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hello Bryan

Thank you again for your answer, it makes a lot of sense!

If I understand correctly, the attribute ref of the model ColumnDataSource (which is the source of my figure) should return a different ID on every connection?

I have tested this and they actually return the same ID. Which would imply this is the exact problem.

My ColumnDataSource is made at the top of the file I run with “bokeh serve”. I have moved those lines into some functions in a separate module, like you proposed.

This actually generates models with a different ID, so that’s actually working! This is something I would’ve never thought of.

Making progress. I can now finally view plots on multiple browser tabs. However, only the plot of the browser that is last connected is updating. The other plots just freeze.

If I refresh 1 of the freezed plots, it starts updating again, but the other one freezes and so on. Is it possible that the RunTimeError “pending writes should be non-None when we have a document lock,…” has something to do with this?

···

Op donderdag 3 mei 2018 21:46:12 UTC+2 schreef Bryan Van de ven:

In that case I suspect the issue is actually in the file you run with “bokeh serve”. That message indicates that some Bokeh model is getting created once, is is trying to be used for multiple sessions. This could happen e.g. if you define a Bokeh model as a top level module-variable in some separate module that you import. Because python caches module imports, only one Bokeh model gets created, and then reused for every connection. But Bokeh models cannot be re-used between connections. A solution might be to have the separate module define functions that create and return the Bokeh models, then the main app script can call the function to get brand new instances on every connection. This is just one possible scenario, but that is definitely ultimately what is happening based on the error message.

Thanks,

Bryan

On May 3, 2018, at 13:37, Arthur [email protected] wrote:

Hello Bryan

Thank you so much for answering. I was under the impression a session needed to be open as long as the browser is on that page.

I have removed the following lines:

session.document.roots[0].title.text = "Plot"
session.push()

so that the plots get updated again and have added:

session.close()

as suggested in issue 7724.

However, I still get the same error: Model must be owned by a single doc. Rendering a keyerror in my browser. Which I find odd, as the sessions get closed.

Thanks,

Arthur

Op donderdag 3 mei 2018 20:15:24 UTC+2 schreef Bryan Van de ven:

Hi,

I think you are running into this:

    [https://github.com/bokeh/bokeh/issues/7724](https://github.com/bokeh/bokeh/issues/7724)

As described there, you can try explicitly calling “session.close()” in your current code. In the next release, there is a new context manager that should be used that takes care of this:

    [https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client](https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client)

For now, you could also try this new context manager out by installing a “dev build”

Thanks,

Bryan

On May 3, 2018, at 12:55, Arthur [email protected] wrote:

Hello

I’ve been at this for a couple of weeks now, and I can’t seem to figure it out, however, I feel like I’m really close.
I’ve tried alot of things, but I was able to simplify it to these 2 code snippets.

Here is a code snippet of the file I run with bokeh serve:
curdoc().add_root(fig)
curdoc().add_periodic_callback(…,100)

In my views.py in Django, I do the following (code snippet):

def index(request):
session = pull_session(url = …)
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})

This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).

However, I cannot get multiple users see this plot. “Model must be owned by single document”

After researching, I found a post about this exact problem. I had to add the following in my view:

def index(request):
session = pull_session(url = …)
session.document.roots[0].title.text = “Plot”
session.push()
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})

I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I’m not sure about this.

Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn’t get streamed anymore.

Could anyone help me with this problem?

Thank you in advance


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/8e3750b6-0ef3-4b82-910c-0ea68d66f639%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/e9b8842c-66e9-41f2-a04f-98bbf050bb05%40continuum.io.

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

Hi,

I’m just not sure offhand without seeing more code. Can you provide a minimal compete example that reproduces this situation?

Thanks,

Bryan

···

On May 3, 2018, at 15:32, Arthur [email protected] wrote:

Hello Bryan

Thank you again for your answer, it makes a lot of sense!

If I understand correctly, the attribute ref of the model ColumnDataSource (which is the source of my figure) should return a different ID on every connection?

I have tested this and they actually return the same ID. Which would imply this is the exact problem.

My ColumnDataSource is made at the top of the file I run with “bokeh serve”. I have moved those lines into some functions in a separate module, like you proposed.

This actually generates models with a different ID, so that’s actually working! This is something I would’ve never thought of.

Making progress. I can now finally view plots on multiple browser tabs. However, only the plot of the browser that is last connected is updating. The other plots just freeze.

If I refresh 1 of the freezed plots, it starts updating again, but the other one freezes and so on. Is it possible that the RunTimeError “pending writes should be non-None when we have a document lock,…” has something to do with this?

Op donderdag 3 mei 2018 21:46:12 UTC+2 schreef Bryan Van de ven:

In that case I suspect the issue is actually in the file you run with “bokeh serve”. That message indicates that some Bokeh model is getting created once, is is trying to be used for multiple sessions. This could happen e.g. if you define a Bokeh model as a top level module-variable in some separate module that you import. Because python caches module imports, only one Bokeh model gets created, and then reused for every connection. But Bokeh models cannot be re-used between connections. A solution might be to have the separate module define functions that create and return the Bokeh models, then the main app script can call the function to get brand new instances on every connection. This is just one possible scenario, but that is definitely ultimately what is happening based on the error message.

Thanks,

Bryan

On May 3, 2018, at 13:37, Arthur [email protected] wrote:

Hello Bryan

Thank you so much for answering. I was under the impression a session needed to be open as long as the browser is on that page.

I have removed the following lines:

session.document.roots[0].title.text = "Plot"
session.push()

so that the plots get updated again and have added:

session.close()

as suggested in issue 7724.

However, I still get the same error: Model must be owned by a single doc. Rendering a keyerror in my browser. Which I find odd, as the sessions get closed.

Thanks,

Arthur

Op donderdag 3 mei 2018 20:15:24 UTC+2 schreef Bryan Van de ven:

Hi,

I think you are running into this:

    [https://github.com/bokeh/bokeh/issues/7724](https://github.com/bokeh/bokeh/issues/7724)

As described there, you can try explicitly calling “session.close()” in your current code. In the next release, there is a new context manager that should be used that takes care of this:

    [https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client](https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client)

For now, you could also try this new context manager out by installing a “dev build”

Thanks,

Bryan

On May 3, 2018, at 12:55, Arthur [email protected] wrote:

Hello

I’ve been at this for a couple of weeks now, and I can’t seem to figure it out, however, I feel like I’m really close.
I’ve tried alot of things, but I was able to simplify it to these 2 code snippets.

Here is a code snippet of the file I run with bokeh serve:
curdoc().add_root(fig)
curdoc().add_periodic_callback(…,100)

In my views.py in Django, I do the following (code snippet):

def index(request):
session = pull_session(url = …)
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})

This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).

However, I cannot get multiple users see this plot. “Model must be owned by single document”

After researching, I found a post about this exact problem. I had to add the following in my view:

def index(request):
session = pull_session(url = …)
session.document.roots[0].title.text = “Plot”
session.push()
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})

I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I’m not sure about this.

Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn’t get streamed anymore.

Could anyone help me with this problem?

Thank you in advance


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/8e3750b6-0ef3-4b82-910c-0ea68d66f639%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/e9b8842c-66e9-41f2-a04f-98bbf050bb05%40continuum.io.

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

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/0f2168b3-9f6a-4680-a3b5-fe8f594da7ce%40continuum.io.

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

Hello Bryan

I don’t really have a reproduction that is not embedded in Django.

If I think about it, the reason that an older plot would freeze is that the bokeh server doesn’t update it anymore. Meaning that the bokeh server is “stuck” on the latest connection.

Which would mean that they are handled sequentially instead of parallel.

The file I run using “bokeh serve” is not multi-threaded. Could this be the reason?

I have tried threading the file. Instead of calling the function “update” I did the following:

def initialise()

t = threading.Thread(target=update, args=…)
t.start()

However, the plot does not show anymore this way. Am I on the right tracks, or does the uniqueness of the model and session handle this problem?

Thanks,

Arthur

···

Op donderdag 3 mei 2018 22:55:41 UTC+2 schreef Bryan Van de ven:

Hi,

I’m just not sure offhand without seeing more code. Can you provide a minimal compete example that reproduces this situation?

Thanks,

Bryan

On May 3, 2018, at 15:32, Arthur [email protected] wrote:

Hello Bryan

Thank you again for your answer, it makes a lot of sense!

If I understand correctly, the attribute ref of the model ColumnDataSource (which is the source of my figure) should return a different ID on every connection?

I have tested this and they actually return the same ID. Which would imply this is the exact problem.

My ColumnDataSource is made at the top of the file I run with “bokeh serve”. I have moved those lines into some functions in a separate module, like you proposed.

This actually generates models with a different ID, so that’s actually working! This is something I would’ve never thought of.

Making progress. I can now finally view plots on multiple browser tabs. However, only the plot of the browser that is last connected is updating. The other plots just freeze.

If I refresh 1 of the freezed plots, it starts updating again, but the other one freezes and so on. Is it possible that the RunTimeError “pending writes should be non-None when we have a document lock,…” has something to do with this?

Op donderdag 3 mei 2018 21:46:12 UTC+2 schreef Bryan Van de ven:

In that case I suspect the issue is actually in the file you run with “bokeh serve”. That message indicates that some Bokeh model is getting created once, is is trying to be used for multiple sessions. This could happen e.g. if you define a Bokeh model as a top level module-variable in some separate module that you import. Because python caches module imports, only one Bokeh model gets created, and then reused for every connection. But Bokeh models cannot be re-used between connections. A solution might be to have the separate module define functions that create and return the Bokeh models, then the main app script can call the function to get brand new instances on every connection. This is just one possible scenario, but that is definitely ultimately what is happening based on the error message.

Thanks,

Bryan

On May 3, 2018, at 13:37, Arthur [email protected] wrote:

Hello Bryan

Thank you so much for answering. I was under the impression a session needed to be open as long as the browser is on that page.

I have removed the following lines:

session.document.roots[0].title.text = "Plot"
session.push()

so that the plots get updated again and have added:

session.close()

as suggested in issue 7724.

However, I still get the same error: Model must be owned by a single doc. Rendering a keyerror in my browser. Which I find odd, as the sessions get closed.

Thanks,

Arthur

Op donderdag 3 mei 2018 20:15:24 UTC+2 schreef Bryan Van de ven:

Hi,

I think you are running into this:

    [https://github.com/bokeh/bokeh/issues/7724](https://github.com/bokeh/bokeh/issues/7724)

As described there, you can try explicitly calling “session.close()” in your current code. In the next release, there is a new context manager that should be used that takes care of this:

    [https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client](https://bokeh.pydata.org/en/dev/docs/user_guide/server.html#connecting-with-bokeh-client)

For now, you could also try this new context manager out by installing a “dev build”

Thanks,

Bryan

On May 3, 2018, at 12:55, Arthur [email protected] wrote:

Hello

I’ve been at this for a couple of weeks now, and I can’t seem to figure it out, however, I feel like I’m really close.
I’ve tried alot of things, but I was able to simplify it to these 2 code snippets.

Here is a code snippet of the file I run with bokeh serve:
curdoc().add_root(fig)
curdoc().add_periodic_callback(…,100)

In my views.py in Django, I do the following (code snippet):

def index(request):
session = pull_session(url = …)
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})

This works as expected. The plot gets updated and I see live data on the plot. (the data is coming from a sensor connected to the pi).

However, I cannot get multiple users see this plot. “Model must be owned by single document”

After researching, I found a post about this exact problem. I had to add the following in my view:

def index(request):
session = pull_session(url = …)
session.document.roots[0].title.text = “Plot”
session.push()
script = server_session(None, session_id = session.id, url = …)
return render(request, …, context = {‘script’ : script})

I assume session.push() pushes the session.document to the server, creating a new sessionID on the server so that the next person has a unique sessionID, but I’m not sure about this.

Anyhow, multiple users can now connect and all have an unique sessionID, as expected. However, the plots do not update dynamically anymore. If I refresh the page, the data gets added to the plot, but new data doesn’t get streamed anymore.

Could anyone help me with this problem?

Thank you in advance


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/8e3750b6-0ef3-4b82-910c-0ea68d66f639%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/e9b8842c-66e9-41f2-a04f-98bbf050bb05%40continuum.io.

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

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/0f2168b3-9f6a-4680-a3b5-fe8f594da7ce%40continuum.io.

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