viff

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 diff
     1.1 --- a/apps/benchmark.py	Tue Feb 02 17:08:16 2010 +0100
     1.2 +++ b/apps/benchmark.py	Tue Feb 02 17:09:19 2010 +0100
     1.3 @@ -73,6 +73,8 @@
     1.4  from viff.config import load_config
     1.5  from viff.util import find_prime
     1.6  
     1.7 +commitment = None
     1.8 +pypaillier = None
     1.9  try:
    1.10      import commitment  
    1.11  except ImportError:
    1.12 @@ -80,6 +82,7 @@
    1.13  
    1.14  try:
    1.15      from pypaillier import encrypt_r, decrypt, tripple_2c, tripple_3a
    1.16 +    pypaillier = "PyPaillier is loaded."
    1.17  except:
    1.18      pypaillier = None
    1.19  
     2.1 --- a/viff/runtime.py	Tue Feb 02 17:08:16 2010 +0100
     2.2 +++ b/viff/runtime.py	Tue Feb 02 17:09:19 2010 +0100
     2.3 @@ -525,6 +525,11 @@
     2.4                           help="Collect and print profiling information.")
     2.5          group.add_option("--track-memory", action="store_true",
     2.6                           help="Track memory usage over time.")
     2.7 +        group.add_option("--statistics", action="store_true",
     2.8 +                         help="Print statistics on shutdown.")
     2.9 +        group.add_option("--no-socket-retry", action="store_true",
    2.10 +                         default=False, help="Fail rather than keep retrying "
    2.11 +                         "to connect if port is already in use.")
    2.12  
    2.13          try:
    2.14              # Using __import__ since we do not use the module, we are
    2.15 @@ -539,7 +544,8 @@
    2.16                              ssl=have_openssl,
    2.17                              deferred_debug=False,
    2.18                              profile=False,
    2.19 -                            track_memory=False)
    2.20 +                            track_memory=False,
    2.21 +                            statistics=False)
    2.22  
    2.23      def __init__(self, player, threshold, options=None):
    2.24          """Initialize runtime.
    2.25 @@ -1023,6 +1029,10 @@
    2.26      runtime = runtime_class(players[id], threshold, options)
    2.27      factory = ShareExchangerFactory(runtime, players, result)
    2.28  
    2.29 +    if options and options.statistics:
    2.30 +        reactor.addSystemEventTrigger("after", "shutdown",
    2.31 +                                      runtime.print_transferred_data)
    2.32 +
    2.33      if options and options.ssl:
    2.34          print "Using SSL"
    2.35          from twisted.internet.ssl import ContextFactory
    2.36 @@ -1068,6 +1078,8 @@
    2.37          try:
    2.38              runtime.port = listen(port)
    2.39          except CannotListenError, e:
    2.40 +            if options and options.no_socket_retry:
    2.41 +                raise
    2.42              delay *= 1 + rand.random()
    2.43              print "Error listening on port %d: %s" % (port, e.socketError[1])
    2.44              print "Will try again in %d seconds" % delay