code: def test_batched_close_abandon():
      # Expect a timeout if the process runs longer than timeout and the config
      # for "datalad.runtime.stalled-external" is "abandon".
      bc = BatchedCommand(
          cmd=[sys.executable, "-i", "-u", "-q", "-"], timeout=0.1
      )
      # Send at least one instruction to start the subprocess
      response = bc("import time; print('a')")
      assert_equal(response, "a")
      bc.stdin_queue.put("time.sleep(2); exit(1)\n".encode())
  
      with unittest.mock.patch("datalad.cmd._cfg_val", "abandon"):
          bc.close(return_stderr=False)
          assert_true(bc.wait_timed_out is True)
          assert_is_none(bc.return_code)
  
file_path: datalad/datalad/tests/test_cmd.py
imports: import sys
  import unittest.mock
  from subprocess import TimeoutExpired
  import pytest
  from datalad.cmd import BatchedCommand, readline_rstripped
  from datalad.cmd import BatchedCommandError
  from datalad.runner.tests.utils import py2cmd
  from datalad.tests.utils_pytest import assert_equal, assert_is_none, assert_is_not_none, assert_not_equal, assert_true
label_desc: Use image node_id 3 for calling a global function with example usage: test_batched_close_abandon() without return types