Skip to content

Commit dd486e5

Browse files
committed
Add heartbeat function to keep connection alive if there is no data to stream within the 60 second window.
1 parent 5335d9e commit dd486e5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

plotly/plotly/plotly.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@ def open(self):
405405
80,
406406
{'Host': streaming_url,
407407
'plotly-streamtoken': self.stream_id})
408+
409+
def heartbeat(self, reconnect_on=(200, '', 408)):
410+
try:
411+
self._stream.write("\n", reconnect_on=reconnect_on)
412+
except AttributeError:
413+
raise exceptions.PlotlyError("Stream has not been opened yet, "
414+
"cannot write to a closed connection. "
415+
"Call `open()` on the stream to open the stream.")
408416

409417
def write(self, data, layout=None, validate=True,
410418
reconnect_on=(200, '', 408)):

0 commit comments

Comments
 (0)