X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftheonering.py;h=4ac5700b07f95fd85da938dba23c07bbc7777a4f;hb=ba13f63fe3f72eee87f43ddceb46d93fbd18dc83;hp=08f3175b0ad7ea92f52e44fde5bb07530a73ef6e;hpb=59c660c24b2df4826c655b7079d32a42ee8b5bd8;p=theonering diff --git a/src/theonering.py b/src/theonering.py index 08f3175..4ac5700 100755 --- a/src/theonering.py +++ b/src/theonering.py @@ -34,9 +34,6 @@ import constants import connection_manager -IDLE_TIMEOUT = 5000 - - def run_theonering(persist): linux_utils.set_process_name(constants.__app_name__) @@ -47,23 +44,26 @@ def run_theonering(persist): raise @gobject_utils.async - def quit(): + def on_quit(): manager.quit() mainloop.quit() def timeout_cb(): if len(manager._connections) == 0: logging.info('No connection received - quitting') - quit() + on_quit() return False if persist: shutdown_callback = None else: - gobject.timeout_add(IDLE_TIMEOUT, timeout_cb) - shutdown_callback = quit + gobject_utils.timeout_add_seconds( + connection_manager.TheOneRingConnectionManager.IDLE_TIMEOUT, + timeout_cb + ) + shutdown_callback = on_quit - signal.signal(signal.SIGTERM, quit) + signal.signal(signal.SIGTERM, lambda: on_quit) try: manager = connection_manager.TheOneRingConnectionManager(shutdown_func=shutdown_callback) @@ -73,6 +73,8 @@ def run_theonering(persist): mainloop = gobject.MainLoop(is_running=True) + gobject.threads_init() + dbus.glib.init_threads() while mainloop.is_running(): try: mainloop.run() @@ -88,23 +90,25 @@ def main(logToFile): raise telepathy_utils.debug_divert_messages(os.getenv('THEONERING_LOGFILE')) + logFormat = '(%(asctime)s) %(levelname)-5s %(threadName)s.%(name)s: %(message)s' + logging.raiseExceptions = True # Getting funky shutdown behavior, checking it out if logToFile: logging.basicConfig( level=logging.DEBUG, filename=constants._user_logpath_, - format='(%(asctime)s) %(levelname)s:%(name)s:%(message)s', + format=logFormat, datefmt='%H:%M:%S', ) else: logging.basicConfig( level=logging.DEBUG, - format='(%(asctime)s) %(levelname)s:%(name)s:%(message)s', + format=logFormat, datefmt='%H:%M:%S', ) logging.info("telepathy-theonering %s-%s" % (constants.__version__, constants.__build__)) - logging.info("OS: %s" % (os.uname()[0], )) - logging.info("Kernel: %s (%s) for %s" % os.uname()[2:]) - logging.info("Hostname: %s" % os.uname()[1]) + logging.debug("OS: %s" % (os.uname()[0], )) + logging.debug("Kernel: %s (%s) for %s" % os.uname()[2:]) + logging.debug("Hostname: %s" % os.uname()[1]) persist = 'THEONERING_PERSIST' in os.environ