5898: Use lsof instead of fuser -- fuser 1234/tcp just hangs on some systems.
authorTom Clegg <tom@curoverse.com>
Thu, 16 Jul 2015 18:33:43 +0000 (14:33 -0400)
committerTom Clegg <tom@curoverse.com>
Thu, 16 Jul 2015 18:33:43 +0000 (14:33 -0400)
sdk/python/tests/run_test_server.py

index 31493cc10ad534989ab1efeb83a661a23bd69b92..1c5162b97d87e476b9ff3badc82ffce3afdd4d28 100644 (file)
@@ -122,16 +122,17 @@ def _wait_until_port_listens(port, timeout=10):
     in seconds), print a warning on stderr before returning.
     """
     try:
-        subprocess.check_output(['fuser', '-l'])
+        subprocess.check_output(['which', 'lsof'])
     except subprocess.CalledProcessError:
-        print("WARNING: No `fuser` -- cannot wait for port to listen. "+
+        print("WARNING: No `lsof` -- cannot wait for port to listen. "+
               "Sleeping 0.5 and hoping for the best.")
         time.sleep(0.5)
         return
     deadline = time.time() + timeout
     while time.time() < deadline:
         try:
-            fuser_says = subprocess.check_output(['fuser', str(port)+'/tcp'])
+            subprocess.check_output(
+                ['lsof', '-t', '-i', 'tcp:'+str(port)])
         except subprocess.CalledProcessError:
             time.sleep(0.1)
             continue