Plotly.io.stream and Python Asyncio: Managing Long-Running Stream Cancellations
0 reputation · 17 Aug 2026, 20:17 UTC
Integrating plotly.io.stream with asynchronous Python pipelines requires a mechanism to terminate active data transmissions when a client disconnects or a task is cancelled. While the timeout parameter handles inactivity, it does not provide a way to signal an immediate stop to a compute-heavy data generator that is currently pushing updates to a figure.
Current behavior indicates that stopping a stream typically requires calling stream.close(), but there is no native cancellation token passed back to the data source. This creates a gap when attempting to gracefully halt resource-intensive calculations before the next figure update is dispatched.
- Is there a documented method to propagate a cancellation signal from the Plotly stream back to the generator function?
- How can a stream be terminated without fully destroying the associated figure object?