borgend/instance.py

changeset 87
a214d475aa28
parent 86
2fe66644c50d
child 89
51cc2e25af38
--- a/borgend/instance.py	Sun Jan 28 17:54:14 2018 +0000
+++ b/borgend/instance.py	Sun Jan 28 19:27:34 2018 +0000
@@ -35,6 +35,7 @@
         self.common_params=common_params
         self.op_params=op_params
         self.paths=paths
+        self.proc=None
 
     def construct_cmdline(self):
         cmd=([settings['borg']['executable']]+necessary_opts+
@@ -124,11 +125,16 @@
                     'message': str(errmsg)}
 
     def terminate(self):
-        self.proc.terminate()
+        if self.proc:
+            self.proc.terminate()
 
-    def wait(self):
-        return self.proc.wait() is not None
+    # Returns True if has terminated
+    def wait(self, timeout=None):
+        if self.proc:
+            return self.proc.wait(timeout=timeout) is not None
+        else:
+            return True
 
     def has_terminated(self):
-        return self.proc.poll() is not None
+        return not self.proc or (self.proc.poll() is not None)
 

mercurial