[tor-commits] [ooni-probe/master] Use is_process_running function in reporter

art at torproject.org art at torproject.org
Mon Sep 19 12:14:25 UTC 2016


commit 379533a802272ad34bbd1353493b6d9bf8d8449b
Author: Arturo Filastò <arturo at filasto.net>
Date:   Fri Sep 16 11:55:57 2016 +0200

    Use is_process_running function in reporter
---
 ooni/reporter.py | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/ooni/reporter.py b/ooni/reporter.py
index b149d49..951602f 100644
--- a/ooni/reporter.py
+++ b/ooni/reporter.py
@@ -17,7 +17,7 @@ from twisted.python.util import untilConcludes
 from twisted.internet import defer
 from twisted.internet.error import ConnectionRefusedError
 
-from ooni.utils import log
+from ooni.utils import log, is_process_running
 from ooni.tasks import Measurement
 try:
     from scapy.packet import Packet
@@ -458,9 +458,7 @@ class OONIBReportLog(object):
             if entry['completed'] is False:
                 continue
             if entry['status'] in ('created',):
-                try:
-                    os.kill(entry['pid'], 0)
-                except OSError:
+                if not is_process_running(entry['pid']):
                     incomplete_reports.append(
                         (entry['measurements_path'], entry)
                     )
@@ -476,13 +474,10 @@ class OONIBReportLog(object):
         all_entries = yield self.get_report_log_entries()
         for entry in all_entries[:]:
             if entry['status'] in ('created',):
-                try:
-                    os.kill(entry['pid'], 0)
+                if is_process_running(entry['pid']):
                     in_progress_reports.append(
                         (entry['measurements_path'], entry)
                     )
-                except OSError:
-                    pass
         defer.returnValue(in_progress_reports)
 
     @defer.inlineCallbacks





More information about the tor-commits mailing list