File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -424,6 +424,21 @@ def __init__(self, stream_id):
424424 self .stream_id = stream_id
425425 self .connected = False
426426
427+ def heartbeat (self , reconnect_on = (200 , '' , 408 )):
428+ """Keep stream alive. Streams will close after ~1 min of inactivity.
429+
430+ If the interval between stream writes is > 30 seconds, you should
431+ consider adding a heartbeat between your stream.write() calls like so:
432+ >>> stream.heartbeat()
433+
434+ """
435+ try :
436+ self ._stream .write ('\n ' , reconnect_on = reconnect_on )
437+ except AttributeError :
438+ raise exceptions .PlotlyError ("Stream has not been opened yet, "
439+ "cannot write to a closed connection. "
440+ "Call `open()` on the stream to open the stream." )
441+
427442 def open (self ):
428443 """Open streaming connection to plotly.
429444
You can’t perform that action at this time.
0 commit comments