Issues (18)

test/test_concurrency.py (1 issue)

1
from threading import Timer
2
3
4
def test_interrupt_from_another_thread(vim):
5
    timer = Timer(0.5, lambda: vim.async_call(lambda: vim.stop_loop()))
6
    timer.start()
7
    assert vim.next_message() is None
8
9
10
def test_exception_in_threadsafe_call(vim):
11
    # an exception in a threadsafe_call shouldn't crash the entire host
12
    msgs = []
13
    vim.async_call(lambda: [vim.eval("3"), undefined_variable])  # noqa: F821
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable undefined_variable does not seem to be defined.
Loading history...
14
    timer = Timer(0.5, lambda: vim.async_call(lambda: vim.stop_loop()))
15
    timer.start()
16
    vim.run_loop(None, None, err_cb=msgs.append)
17
    assert len(msgs) == 1
18
    msgs[0].index('NameError')
19
    msgs[0].index('undefined_variable')
20