11910: Fix racy tests: ignore non-matching logs from previous tests.
[arvados.git] / crunch_scripts / run-command
index 266a12d237a9d953889b3f2edcc86db859503540..3fd08bf28b714cbab425c7fa7cb404946c104133 100755 (executable)
@@ -1,4 +1,7 @@
 #!/usr/bin/env python
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
 
 import logging
 
@@ -399,16 +402,17 @@ try:
     while len(pids) > 0:
         try:
             (pid, status) = os.wait()
-            pids.discard(pid)
-            if not taskp.get("task.ignore_rcode"):
-                rcode[pid] = (status >> 8)
-            else:
-                rcode[pid] = 0
         except OSError as e:
             if e.errno == errno.EINTR:
                 pass
             else:
                 raise
+        else:
+            pids.discard(pid)
+            if not taskp.get("task.ignore_rcode"):
+                rcode[pid] = (status >> 8)
+            else:
+                rcode[pid] = 0
 
     if sig.sig is not None:
         logger.critical("terminating on signal %s" % sig.sig)