code: def test_stalling(kill=False):
      import concurrent.futures
  
      from datalad.runner.coreprotocols import StdOutErrCapture
      from datalad.runner.runner import WitlessRunner
  
      def worker():
          return WitlessRunner().run(["echo", "1"], StdOutErrCapture)
  
      t0 = time()
      result1 = worker()
      dt1 = time() - t0
  
      t0 = time()
      with concurrent.futures.ThreadPoolExecutor(1) as executor:
          future = executor.submit(worker)
          dt2_limit = max((5, dt1 * 100))
          while not future.done():
              sleep(dt1 / 3)
              if time() - t0 > dt2_limit:
                  # does not even shutdown
                  # executor.shutdown(wait=False)
                  if kill:
                      # raising an exception isn't enough!
                      print("exceeded")
                      import os
                      import signal
  
                      os.kill(os.getpid(), signal.SIGTERM)
                  raise AssertionError(
                      f"Future has not finished in {dt2_limit}s"
                  )
          result2 = future.result()
      assert result1 == result2
  
file_path: datalad/datalad/support/tests/test_parallel.py
imports: import logging
  from functools import partial
  from time import sleep, time
  import pytest
  from datalad import lgr
  from datalad.support import path
  from datalad.support.exceptions import IncompleteResultsError
  from datalad.support.parallel import ProducerConsumer, ProducerConsumerProgressLog, no_parentds_in_futures
  from datalad.tests.utils_pytest import assert_equal, assert_greater, assert_greater_equal, assert_raises, assert_repo_status, known_failure_osx, on_osx, on_windows, rmtree, skip_if, slow, with_tempfile
label_desc: Use image node_id 7 for calling a global function with example usage: test_stalling(kill) and returns: WitlessRunner