code: def function_call_with_timeout(fun_name, fun_args, secs=5):
      
      from multiprocessing import Process, Queue
      p = Process(target=fun_name, args=tuple(fun_args))
      p.start()
      curr_secs = 0
      no_timeout = False
      if secs == 0: no_timeout = True
      else: timeout = secs
      while p.is_alive() and not no_timeout:
          if curr_secs > timeout:
              print("Process time has exceeded timeout, terminating it.")
              p.terminate()
              return False
          time.sleep(0.1)
          curr_secs += 0.1
      p.join() # Blocks if process hasn't terminated.
      return True
docs: Run a Python function with a timeout.  No interprocess communication or
      return values are handled.  Setting secs to 0 gives infinite timeout.