summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIke Devolder <ike.devolder@gmail.com>2019-07-04 23:33:09 +0200
committerGitHub <noreply@github.com>2019-07-04 23:33:09 +0200
commit1006a5ae7bfb2adc36c5085c0af625e0cc6deff3 (patch)
tree233ea75aa2cb43ce7d293598c5f9b9c685ead157
parentf16351a94bc784a7c5e20e4b1a08f2f4de34f2be (diff)
parent8736ee2cabf41a972eb80e81c1a3190884432104 (diff)
downloadvdebug-1006a5ae7bfb2adc36c5085c0af625e0cc6deff3.zip
Merge pull request #406 from Garethp/heartbeat
Adding a heartbeat
-rw-r--r--python3/vdebug/session.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/python3/vdebug/session.py b/python3/vdebug/session.py
index 2e0f5d0..c12188d 100644
--- a/python3/vdebug/session.py
+++ b/python3/vdebug/session.py
@@ -1,4 +1,5 @@
import socket
+import threading
import vim
@@ -41,6 +42,18 @@ class SessionHandler:
else:
self.start_listener()
+ def heartbeat(self):
+ try:
+ res = self.session().api().status()
+
+ if str(res) in ("stopping", "stopped"):
+ self.dispatch_event("refresh", res)
+ return
+
+ threading.Timer(2.0, self.heartbeat).start()
+ except:
+ self.dispatch_event("refresh", "stopped")
+
def start_listener(self):
self.listener = listener.Listener.create()
print("Vdebug will wait for a connection in the background")
@@ -118,6 +131,7 @@ class SessionHandler:
status = self.__session.start(self.listener.create_connection())
log.Log("refresh event", log.Logger.DEBUG)
self.dispatch_event("refresh", status)
+ threading.Timer(2.0, self.heartbeat).start()
class Session: