Closed jakevdp closed 6 years ago
canvas.close()
disconnects the server-side event stream. If you have a reference to the Canvas
when you want it to go away, call close
on it and the browser tab will go grey. Then you don't have the awkward situation in which the Python process doesn't close. Although the browser tab doesn't close, going grey is a good hint to the user that it's no longer useful.
I could perhaps register an atexit
hook for every Canvas
to close automatically at process shutdown. Would that be preferable?
(I didn't realize I was commenting on my own project here— I thought this was an Altair PR that you referenced me on.) Sure I'll accept it!
Actually, atexit
wasn't necessary. I had overlooked a feature of ThreadingTCPServer
that made all of the threads it spawned non-daemon. Turning that off (making them daemon), the Python process now ends cleanly even without explicitly calling close()
.
When the Python process exits, any browser tabs open to VegaScope will go gray.
Both updates are now on PyPI as vegascope>=1.0.7
.
Awesome – thanks for the quick merge!
This adds the mechanism necessary for Altair to use vegascope as a renderer.
Usage from altair looks like this, and works without any changes to the released version of altair as long as vegascope is installed:
when the chart is evaluated, it launches a vegascope local canvas and displays the chart. Any additional chart is then displayed on the same canvas.
The one awkward thing is that the canvas never shuts itself down... I'd be curious if you have ideas on how to do that gracefully.