viff

changeset 1427:2324d01c74e2

Added option to avoid retrying to connect if socket is already in use. In some situations it turns out to be more convenient to have VIFF throw an exception rather than keep retrying to connect to a socket with exponentially increasing delays. This is now possible using the new command line parameter --no-socket-retry.
author Thomas P Jakobsen <tpj@cs.au.dk>
date Wed, 20 Jan 2010 08:54:41 +0100
parents efa1983063d6
children e120e8967257
files viff/runtime.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Thu Jan 14 11:36:13 2010 +0100
     1.2 +++ b/viff/runtime.py	Wed Jan 20 08:54:41 2010 +0100
     1.3 @@ -525,6 +525,9 @@
     1.4                           help="Collect and print profiling information.")
     1.5          group.add_option("--track-memory", action="store_true",
     1.6                           help="Track memory usage over time.")
     1.7 +        group.add_option("--no-socket-retry", action="store_true",
     1.8 +                         default=False, help="Fail rather than keep retrying "
     1.9 +                         "to connect if port is already in use.")
    1.10  
    1.11          try:
    1.12              # Using __import__ since we do not use the module, we are
    1.13 @@ -1068,6 +1071,8 @@
    1.14          try:
    1.15              runtime.port = listen(port)
    1.16          except CannotListenError, e:
    1.17 +            if options and options.no_socket_retry:
    1.18 +                raise
    1.19              delay *= 1 + rand.random()
    1.20              print "Error listening on port %d: %s" % (port, e.socketError[1])
    1.21              print "Will try again in %d seconds" % delay