def run(self):
"""
Registers advertisement and services to D-Bus and starts the main loop.
"""
if self._main_loop:
return
self._main_loop = GObject.MainLoop()
self._disconnect_all()
self._register()
logger.info("--- Mainloop started ---")
try:
self._main_loop.run()
except KeyboardInterrupt:
# ignore exception as it is a valid way to exit the program
# and skip to finally clause
pass
except Exception as e:
logger.error(e)
finally:
logger.info("--- Mainloop finished ---")
self._unregister()
self._main_loop.quit()
self._main_loop = None
评论列表
文章目录