Salome HOME
Copyright update 2020
[modules/kernel.git] / bin / appliskel / tests / concurrentSession / TestConcurrentSession.py
old mode 100644 (file)
new mode 100755 (executable)
index 095a97b..cda7592
@@ -1,4 +1,5 @@
-# Copyright (C) 2013-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+#!/usr/bin/env python3
+# Copyright (C) 2013-2020  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -44,7 +45,10 @@ class TestConcurrentLaunch(unittest.TestCase):
     return running_instances, processes
   #
   def __terminateInstances(self, running_instances):
-    while not running_instances.empty():
+    import time
+    timeout = time.time() + 60*10 # the test duration is about 50 s, we reasonably assume a max duration of 10mn
+
+    while not running_instances.empty() and time.time() < timeout:
       instance = running_instances.get()
       print("Terminate instance running on port", instance.get_port())
       instance.stop()
@@ -122,9 +126,5 @@ class TestConcurrentLaunch(unittest.TestCase):
 #
 
 if __name__ == "__main__":
-  if not os.path.isfile("hello.py"):
-    with open("hello.py", "w") as f:
-      f.write("print('Hello!')")
-
   unittest.main()
 #