[tracker/sam/test-fixes: 4/7] trackertestutils: Fix crash if miner-fs isn't running



commit 9f10204fc5bbe7518deb37dacbca42a962dd0905
Author: Sam Thursfield <sam afuera me uk>
Date:   Mon Apr 27 19:24:19 2020 +0200

    trackertestutils: Fix crash if miner-fs isn't running
    
    Calling .stop_miner_fs() could trigger a crash if the miner
    wasn't running (perhaps if it had itself crashed).

 utils/trackertestutils/helpers.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/utils/trackertestutils/helpers.py b/utils/trackertestutils/helpers.py
index 08df8b470..a8f695665 100644
--- a/utils/trackertestutils/helpers.py
+++ b/utils/trackertestutils/helpers.py
@@ -491,7 +491,8 @@ class TrackerDBusSandbox:
         for busname in self.daemon.list_names_sync():
             if busname.startswith('org.freedesktop.Tracker3'):
                 pid = self.daemon.get_connection_unix_process_id_sync(busname)
-                tracker_processes.append(pid)
+                if pid is not None:
+                    tracker_processes.append(pid)
 
         log.info("Terminating %i Tracker processes", len(tracker_processes))
         for pid in tracker_processes:
@@ -513,8 +514,11 @@ class TrackerDBusSandbox:
     def stop_miner_fs(self):
         log.info("Stopping tracker-miner-fs process.")
         pid = self.daemon.get_connection_unix_process_id_sync('org.freedesktop.Tracker1.Miner.Files')
-        os.kill(pid, signal.SIGTERM)
-        psutil.wait_pid(pid)
+        if pid:
+            os.kill(pid, signal.SIGTERM)
+            psutil.wait_pid(pid)
+        else:
+            log.info("tracker-miner-fs process was not found on the message bus.")
 
     def get_connection(self):
         return self.daemon.get_connection()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]