Good to know, thank you. Right now I am working on a local network, but still there might be some problem accessing the server especially when the request rate is high. This doesn’t seem my case right now, but as Fabio suggested I can try with a static html page to exclude a variable.
Thank you for your explanation of session.publish, as you hypothesized I don’t need it. I agree with you that coupling a session and a document doesn’t seem to be the right way to go, but I can imagine that a project in rapid evolution such as Bokeh needs some refactoring from time to time as new things pop out. 
···
Francesco
On Wed, Mar 25, 2015 at 12:23 PM, Fabio Pliger fabio.pliger@continuum.io wrote:
Hi Francesco,
I’ve taken a quick look at your code. As Hugo already mentioned the single session seems to not be very happy when you call it with other documents. So you actually should create a separate sessions per document. Also, I’ve seen that you seem to be re-storing the entire document when you update just one value (inside the do method). That is not convenient and you can just store the plot source.
One thing that I didn’t ask before was if the code fails when you create the plot or when it updates the plot with new data. If it’s when you create the plot, have you actually tried to check if you code generate static plots correctly?
Anyway, I’m posting a code here with 2 plots being live updated at the same time on bokeh-server.
import time
import numpy as np
from bokeh.plotting import *
N = 80
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
yy = np.cos(x)
session1 = Session()
session2 = Session()
output_server(‘sindoc’, session=session1)
p = figure()
p.line(x, y, color=“#3333ee”, name=“sin”)
p.line([0,4*np.pi], [-1, 1], color=“#ee3333”)
renderer = p.select(dict(name=“sin”))
ds = renderer[0].data_source
show(p)
output_server(‘cosdoc’, session=session2)
pp = figure()
pp.line(x, yy, color=“#3333ee”, name=“cos”)
renderer = pp.select(dict(name=“cos”))
dds = renderer[0].data_source
show(pp)
while True:
for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))):
ds.data[“y”] = y * i
dds.data[“y”] = y * i
# just update the data source on the server
session1.store_objects(ds)
session2.store_objects(dds)
time.sleep(0.05)
``
This is just a simple example but should give you an idea of the pattern. Please let me know if it helps…
Cheers
Fabio
On Wednesday, March 25, 2015 at 2:40:15 PM UTC+1, Hugo Shi wrote:
Ok - this is unfortunately quite confusing at the moment, I’ve thought about how we should fix the API but we havne’t done anything around it.
A session starts out unassociated with a document, but after calling use_doc, it becomes associated with a specific document. I’m not sure if it can be used with other documents or not after that point - it’s not tested, and I would not be that suprised if it was broken (though we should be able to make it work better)
session.publish is used for setting permissions on the bokeh server to put the document in public mode (so everyone can view it) If you’re running in single user mode (which you probably are) Then this isn’t important
–
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/48053590-182e-46b9-bcf4-80abf428ded9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
On Wed, Mar 25, 2015 at 12:23 PM, Fabio Pliger fabio.pliger@continuum.io wrote:
Hi Francesco,
I’ve taken a quick look at your code. As Hugo already mentioned the single session seems to not be very happy when you call it with other documents. So you actually should create a separate sessions per document. Also, I’ve seen that you seem to be re-storing the entire document when you update just one value (inside the do method). That is not convenient and you can just store the plot source.
One thing that I didn’t ask before was if the code fails when you create the plot or when it updates the plot with new data. If it’s when you create the plot, have you actually tried to check if you code generate static plots correctly?
Anyway, I’m posting a code here with 2 plots being live updated at the same time on bokeh-server.
import time
import numpy as np
from bokeh.plotting import *
N = 80
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
yy = np.cos(x)
session1 = Session()
session2 = Session()
output_server(‘sindoc’, session=session1)
p = figure()
p.line(x, y, color=“#3333ee”, name=“sin”)
p.line([0,4*np.pi], [-1, 1], color=“#ee3333”)
renderer = p.select(dict(name=“sin”))
ds = renderer[0].data_source
show(p)
output_server(‘cosdoc’, session=session2)
pp = figure()
pp.line(x, yy, color=“#3333ee”, name=“cos”)
renderer = pp.select(dict(name=“cos”))
dds = renderer[0].data_source
show(pp)
while True:
for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))):
ds.data[“y”] = y * i
dds.data[“y”] = y * i
# just update the data source on the server
session1.store_objects(ds)
session2.store_objects(dds)
time.sleep(0.05)
``
This is just a simple example but should give you an idea of the pattern. Please let me know if it helps…
Cheers
Fabio
On Wednesday, March 25, 2015 at 2:40:15 PM UTC+1, Hugo Shi wrote:
Ok - this is unfortunately quite confusing at the moment, I’ve thought about how we should fix the API but we havne’t done anything around it.
A session starts out unassociated with a document, but after calling use_doc, it becomes associated with a specific document. I’m not sure if it can be used with other documents or not after that point - it’s not tested, and I would not be that suprised if it was broken (though we should be able to make it work better)
session.publish is used for setting permissions on the bokeh server to put the document in public mode (so everyone can view it) If you’re running in single user mode (which you probably are) Then this isn’t important
–
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/48053590-182e-46b9-bcf4-80abf428ded9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
Francesco