예제 #1
0
async def testing(group, student_num, file_name):
    q = queue.Queue()
    t = KThread(target=__testing__, args=(group, student_num, file_name, q))
    t.start()
    await asyncio.sleep(5)
    if t.is_alive():
        t.kill()
    return q.get()
예제 #2
0
        def the_wrapper_around_the_original_function(*args, **kwargs):
            from kthread import KThread
            thread = KThread(
                target=lambda: function_to_decorate(*args, **kwargs))
            thread.start()
            thread.join(timeout=seconds)

            if thread.is_alive():
                thread.kill()

                if raise_timeout:
                    raise TimeoutError()