code: def test_batched_close_ok():
      # Expect a long wait and no timeout if the process runs longer than timeout
      # seconds and the config for "datalad.runtime.stalled-external" has its
      # default value.
      bc = BatchedCommand(
          cmd=[sys.executable, "-i", "-u", "-q", "-"], timeout=2
      )
      # 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(.5); exit(3)\n".encode())
      bc.close(return_stderr=False)
      assert_true(bc.wait_timed_out is False)
      assert_equal(bc.return_code, 3)
  
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 6 for calling a global function with example usage: test_batched_close_ok() without return types