|
@@ -1,6 +1,7 @@
|
|
|
#! /usr/bin/python
|
|
|
#
|
|
|
-# Find an instance amongst all profile configured.
|
|
|
+# Find an instance amongst all profile configured. Note that it makes multiple calls
|
|
|
+# to the FindInstanceInProfile.py in parallel.
|
|
|
#
|
|
|
# Unbuffered, no CRLF print:
|
|
|
from __future__ import print_function
|
|
@@ -20,7 +21,7 @@ except ImportError:
|
|
|
# 1 = Show progress
|
|
|
# 2 = Informational
|
|
|
# 5 = Include boto3 logging
|
|
|
-DEBUG=2
|
|
|
+DEBUG=0
|
|
|
|
|
|
if len(sys.argv) != 2:
|
|
|
print("Usage: " + os.path.basename(sys.argv[0]) + " <searchstring>")
|
|
@@ -43,10 +44,21 @@ for line in cfile:
|
|
|
|
|
|
# End of for line
|
|
|
FOUND=0
|
|
|
+processes = set()
|
|
|
for profile in profiles:
|
|
|
if DEBUG >= 2:
|
|
|
print("Searching profile " + profile)
|
|
|
- returncode = subprocess.call(['FindInstanceInProfile.py', SEARCHSTRING, profile])
|
|
|
+# returncode = subprocess.call(['FindInstanceInProfile.py', SEARCHSTRING, profile])
|
|
|
+ process = subprocess.Popen(['FindInstanceInProfile.py', SEARCHSTRING, profile])
|
|
|
+ if DEBUG >= 2:
|
|
|
+ print("PID = " + str(process.pid))
|
|
|
+ processes.add(process)
|
|
|
+# We should have spawned all child processes. Let's wait for them.
|
|
|
+
|
|
|
+for process in processes:
|
|
|
+ if DEBUG >= 2:
|
|
|
+ print("Waiting on process " + str(process.pid))
|
|
|
+ returncode = process.wait()
|
|
|
if(returncode == 0):
|
|
|
# Found one
|
|
|
FOUND = FOUND + 1
|