code: def test_thread_leave_handling() -> None:
      # expect no exception on repeated call to run of a runner with
      # generator-protocol, if the generator was exhausted before the second call
  
      thread_1, thread_2, exception = _get_run_on_threads(
          MinimalStdOutGeneratorProtocol, True
      )
  
      thread_1.start()
      thread_1.join()
  
      thread_2.start()
      thread_2.join()
  
      assert exception == []
  
imports: from __future__ import annotations
  import random
  import threading
  import time
  from threading import Thread
  from datalad.tests.utils_pytest import assert_raises
  from ..coreprotocols import StdOutCapture
  from ..nonasyncrunner import ThreadedRunner
  from ..protocol import GeneratorMixIn, WitlessProtocol
  from .utils import py2cmd
label_desc: Use image node_id 8 for calling a global function with example usage: test_thread_leave_handling() without return types