Example #1
0
    #     st = Thread(name=thread_name, target=func_with_check_stop, args=(10, res, check_stop))
    #     st.start()
    #     sleep(1)
    #     stop_flag[thread_name] = True
    #     st.join()
    #     res.p()
    #     "ok".p()

    with test(func_with_check_stop2):
        res = [""]
        stop_flag = {}
        thread_name = "thread1"
        st = Thread(name=thread_name, target=func_with_check_stop2, args=(10, res))
        # st.need_stop = False
        st.start()
        sleep(1)
        st.need_stop = True
        st.join()
        res.p()
        "ok".p()

#     with test():
# def foo(bar, baz):
#   print('hello {0}'.format(bar))
#   return 'foo' + baz

# from multiprocessing.pool import ThreadPool
# pool = ThreadPool(processes=1)

# async_result = pool.apply_async(foo, ('world', 'foo'))