changeset 1431:4efa3caf521e

Merged.
author Thomas P Jakobsen <tpj@cs.au.dk>
date Tue, 02 Feb 2010 17:09:19 +0100
parents 0164b895d948 b2b8e4a74cd6
children da995056d761
files
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/apps/benchmark.py	Tue Feb 02 17:08:16 2010 +0100
+++ b/apps/benchmark.py	Tue Feb 02 17:09:19 2010 +0100
@@ -73,6 +73,8 @@
 from viff.config import load_config
 from viff.util import find_prime
 
+commitment = None
+pypaillier = None
 try:
     import commitment  
 except ImportError:
@@ -80,6 +82,7 @@
 
 try:
     from pypaillier import encrypt_r, decrypt, tripple_2c, tripple_3a
+    pypaillier = "PyPaillier is loaded."
 except:
     pypaillier = None
 
--- a/viff/runtime.py	Tue Feb 02 17:08:16 2010 +0100
+++ b/viff/runtime.py	Tue Feb 02 17:09:19 2010 +0100
@@ -525,6 +525,11 @@
                          help="Collect and print profiling information.")
         group.add_option("--track-memory", action="store_true",
                          help="Track memory usage over time.")
+        group.add_option("--statistics", action="store_true",
+                         help="Print statistics on shutdown.")
+        group.add_option("--no-socket-retry", action="store_true",
+                         default=False, help="Fail rather than keep retrying "
+                         "to connect if port is already in use.")
 
         try:
             # Using __import__ since we do not use the module, we are
@@ -539,7 +544,8 @@
                             ssl=have_openssl,
                             deferred_debug=False,
                             profile=False,
-                            track_memory=False)
+                            track_memory=False,
+                            statistics=False)
 
     def __init__(self, player, threshold, options=None):
         """Initialize runtime.
@@ -1023,6 +1029,10 @@
     runtime = runtime_class(players[id], threshold, options)
     factory = ShareExchangerFactory(runtime, players, result)
 
+    if options and options.statistics:
+        reactor.addSystemEventTrigger("after", "shutdown",
+                                      runtime.print_transferred_data)
+
     if options and options.ssl:
         print "Using SSL"
         from twisted.internet.ssl import ContextFactory
@@ -1068,6 +1078,8 @@
         try:
             runtime.port = listen(port)
         except CannotListenError, e:
+            if options and options.no_socket_retry:
+                raise
             delay *= 1 + rand.random()
             print "Error listening on port %d: %s" % (port, e.socketError[1])
             print "Will try again in %d seconds" % delay