def main_loop():
loop = GLib.MainLoop()
timeout = GLib.Timeout(RUN_TIMEOUT)
timeout.set_callback(lambda loop: loop.quit(), loop)
timeout.attach()
return loop
# https://github.com/Mirantis/ceph-lcm/blob/1b95e76503d9869da4bf4e91e24c848d3f683624/tests/controller/test_mainloop.py
# @pytest.fixture(scope='function')
# def main_loop_threading():
# thread = threading.Thread(target=mainloop.main)
# thread.start()
#
# return thread
#
#
# def test_shutdown_callback(main_loop_threading):
# time.sleep(.5)
#
# assert main_loop_threading.is_alive()
# mainloop.shutdown_callback()
#
# time.sleep(.5)
# assert not main_loop_threading.is_alive()
评论列表
文章目录