code: def wait_and_check(args, processes, force=False):
      if not force and len(processes) < args.max_threads:
          return None
  
      test_path = processes[0][0]
      test_name = test_path.split("/")[-1]
      log_file_name = processes[0][1]
      p = processes[0][2]
      p.wait()
  
      filename_pattern = "*.csv"
  
      # get the csv with the results
      csv_paths = read_csv_paths(test_path, filename_pattern)
  
      test_passed = False
      screen.log("Results for {}: ".format(test_name[13:]))
      if not csv_paths:
          screen.error("csv file never found", crash=False)
          if args.verbose:
              screen.error(
                  "command exitcode: {}".format(p.returncode),
                  crash=False,
              )
              screen.error(open(log_file_name).read(), crash=False)
      else:
          trace_path = os.path.join(
              "./rl_coach", "traces", test_name[13:]
          )
          if not os.path.exists(trace_path):
              screen.log(
                  "No trace found, creating new trace in: {}".format(
                      trace_path
                  )
              )
              os.makedirs(trace_path)
              df = pd.read_csv(csv_paths[0])
              df = clean_df(df)
              try:
                  df.to_csv(
                      os.path.join(trace_path, "trace.csv"), index=False
                  )
              except:
                  pass
              screen.success("Successfully created new trace.")
              test_passed = True
          else:
              test_df = pd.read_csv(csv_paths[0])
              test_df = clean_df(test_df)
              new_trace_csv_path = os.path.join(
                  trace_path, "trace_new.csv"
              )
              test_df.to_csv(new_trace_csv_path, index=False)
              test_df = pd.read_csv(new_trace_csv_path)
              trace_csv_path = glob.glob(
                  path.join(trace_path, "trace.csv")
              )
              trace_csv_path = trace_csv_path[0]
              trace_df = pd.read_csv(trace_csv_path)
              test_passed = test_df.equals(trace_df)
              if test_passed:
                  screen.success("Passed successfully.")
                  os.remove(new_trace_csv_path)
                  test_passed = True
              else:
                  screen.error("Trace test failed.", crash=False)
                  if args.overwrite:
                      os.remove(trace_csv_path)
                      os.rename(new_trace_csv_path, trace_csv_path)
                      screen.error(
                          "Overwriting old trace.", crash=False
                      )
                  else:
                      screen.error(
                          "bcompare {} {}".format(
                              trace_csv_path, new_trace_csv_path
                          ),
                          crash=False,
                      )
  
      shutil.rmtree(test_path)
      os.remove(log_file_name)
      processes.pop(0)
      return test_passed
  
imports: import argparse
  import glob
  import os
  import shutil
  import subprocess
  import multiprocessing
  import sys
  import signal
  import pandas
  import time
  from configparser import ConfigParser
  from importlib import import_module
  from os import path
  from rl_coach.logger import screen
label_desc: Use image node_id 5 for calling a global function with example usage: wait_and_check(args, processes, force) and returns: test_passed, None