def append_in_thread(l, f, *args, **kwargs):
    started = threading.Event()
    done = threading.Event()
    def go():
        started.set()
        try:
            result = f(*args, **kwargs)
        except Exception as e:
            l.extend([False, e])
        else:
            l.extend([True, result])
        done.set()
    threading.Thread(target=go).start()
    started.wait()
    return done
Call a function in a thread, append its result to the given list.
dataset/ETHPy150Open itamarst/crochet/crochet/tests/test_api.py/append_in_thread