From: Daira Hopwood Date: Tue, 28 May 2013 18:44:02 +0000 (+0100) Subject: iputil.py: retry address queries on EINTR. fixes #1381 X-Git-Tag: allmydata-tahoe-1.10.1a1~237 X-Git-Url: https://git.rkrishnan.org/module-simplejson.scanner.html?a=commitdiff_plain;h=6a445d73bc5253ec4ae0dec70af02e33bc869cf6;p=tahoe-lafs%2Ftahoe-lafs.git iputil.py: retry address queries on EINTR. fixes #1381 Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/util/iputil.py b/src/allmydata/util/iputil.py index 85b3b1d3..1c8ba3ed 100644 --- a/src/allmydata/util/iputil.py +++ b/src/allmydata/util/iputil.py @@ -1,5 +1,5 @@ # from the Python Standard Library -import os, re, socket, sys, subprocess +import os, re, socket, sys, subprocess, errno # from Twisted from twisted.internet import defer, threads, reactor @@ -235,8 +235,14 @@ def _synchronously_find_addresses_via_config(): def _query(path, args, regex): env = {'LANG': 'en_US.UTF-8'} - p = subprocess.Popen([path] + list(args), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) - (output, err) = p.communicate() + for trial in xrange(5): + try: + p = subprocess.Popen([path] + list(args), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) + (output, err) = p.communicate() + break + except OSError, e: + if e.errno == errno.EINTR: + continue addresses = [] outputsplit = output.split('\n')