still making both branches closer
[nepi.git] / src / nepi / util / sshfuncs.py
index 1899de2..0d0c17d 100644 (file)
@@ -208,7 +208,7 @@ def eintr_retry(func):
     @functools.wraps(func)
     def rv(*p, **kw):
         retry = kw.pop("_retry", False)
-        for i in xrange(0 if retry else 4):
+        for i in range(0 if retry else 4):
             try:
                 return func(*p, **kw)
             except (select.error, socket.error) as args:
@@ -554,7 +554,7 @@ def rgetpid(pidfile,
     
     if out:
         try:
-            return map(int,out.strip().split(' ',1))
+            return [ int(x) for x in out.strip().split(' ',1)) ]
         except:
             # Ignore, many ways to fail that don't matter that much
             return None
@@ -697,7 +697,7 @@ def _retry_rexec(args,
                  tmp_known_hosts = None,
                  blocking = True):
 
-    for x in xrange(retry):
+    for x in range(retry):
         # display command actually invoked when debug is turned on
         message = " ".join( [ "'{}'".format(arg) for arg in args ] )
         log("sshfuncs: invoking {}".format(message), logging.DEBUG)
@@ -722,7 +722,9 @@ def _retry_rexec(args,
                 # The method communicate was re implemented for performance issues
                 # when using python subprocess communicate method the ssh commands 
                 # last one minute each
+                #log("BEFORE communicate", level=logging.INFO); import time; beg=time.time()
                 out, err = _communicate(proc, input=None)
+                #log("AFTER communicate - {}s".format(time.time()-beg), level=logging.INFO)
 
             elif stdout:
                 out = proc.stdout.read()