|
@@ -19,25 +19,16 @@ from check_objects import to_recompile
|
|
|
username = "test_user"
|
|
|
parallel_push = True
|
|
|
|
|
|
-ports = []
|
|
|
+ports = set()
|
|
|
|
|
|
def getFreePort():
|
|
|
+ """Gets a unique new port."""
|
|
|
while 1:
|
|
|
port = random.randint(10000, 20000)
|
|
|
- ports.append(port)
|
|
|
-
|
|
|
- exists = False
|
|
|
- for p in ports:
|
|
|
- if p == port:
|
|
|
- if not exists:
|
|
|
- # We have hopefully found our own
|
|
|
- exists = True
|
|
|
- else:
|
|
|
- # We seem to be the second entry, so chose another one
|
|
|
- ports.remove(port)
|
|
|
- break
|
|
|
- else:
|
|
|
- # Didn't find a duplicate
|
|
|
+ # Check if this port is in the set of ports.
|
|
|
+ if port not in ports:
|
|
|
+ # We have found a unique port. Add it to the set and return.
|
|
|
+ ports.add(port)
|
|
|
return port
|
|
|
|
|
|
def execute(scriptname, parameters=[], wait=False):
|