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

[tor-commits] [ooni-probe/master] Add a shutdown hook for when everything is done



commit 96b6c644955114f17d15da924ad39a5b7c3583d7
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Wed Jan 16 21:02:55 2013 +0100

    Add a shutdown hook for when everything is done
---
 ooni/oonicli.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index ac1b080..71de7e1 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -159,6 +159,13 @@ def parseOptions():
 
     return dict(cmd_line_options)
 
+def shutdown(result):
+    """
+    This will get called once all the operations that need to be done in the
+    current oonicli session have been completed.
+    """
+    reator.stop()
+
 def runWithDirector():
     """
     Instance the director, parse command line options and start an ooniprobe
@@ -185,13 +192,13 @@ def runWithDirector():
 
     director = Director(reporters)
     try:
-        director.startNetTest(net_test_loader, net_test_options)
+        d = director.startNetTest(net_test_loader, net_test_options)
+        d.addBoth(shutdown)
+        reactor.run()
     except MissingRequiredOption, option_name:
         log.err('Missing required option: "%s"' % option_name)
         print options.getUsage()
 
-    reactor.run()
-
 def run():
     """
     Parses command line arguments of test.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits