def METHOD_NAME(self, command):
    """
    Interrupt a subprocess after a second.
    """
    if threading.main_thread() != threading.current_thread():
        raise pytest.skip("Can't run this test if not in main thread.")
    # Some tests can overwrite SIGINT handler (by using pdb for example),
    # which then breaks this test, so just make sure it's operating
    # normally.
    signal.signal(signal.SIGINT, signal.default_int_handler)
    def interrupt():
        # Wait for subprocess to start:
        time.sleep(0.5)
        interrupt_main()
    threading.Thread(target=interrupt).start()
    start = time.time()
    try:
        result = command()
    except KeyboardInterrupt:
        # Success!
        pass
    end = time.time()
    self.assertTrue(
        end - start < 2, "Process didn't die quickly: %s" % (end - start)
    )
    return result