def METHOD_NAME(self):
    result_queue = queue.Queue(1)
    def wait_for_exit_code(client, queue):
        queue.put(client.wait_for_command_exit_code())
    key = secret.make_secret_key()
    service_name = 'test-service'
    service = BasicTaskService(service_name, 0, key, nics=None, verbose=2)
    try:
        client = BasicTaskClient(service_name, service.addresses(), key, verbose=2, attempts=1)
        thread = threading.Thread(target=wait_for_exit_code, args=(client, result_queue))
        start = time.time()
        thread.start()  # wait for command exit code
        client.run_command('sleep 2', {})  # execute command
        time.sleep(0.5)  # give the thread some time to connect before shutdown
    finally:
        service.shutdown()  # shutdown should wait on request to finish
    duration = time.time() - start
    self.assertGreaterEqual(duration, 2)
    # we cannot call after shutdown
    with pytest.raises(Exception, match=r'^(\[[Ee]rrno 104\] Connection reset by peer)'
                                        r'|(\[[Ee]rrno 111\] Connection refused)$'):
        client.command_result()
    # but still our long running request succeeded
    thread.join(1.0)
    self.assertFalse(thread.is_alive())