From fe16d52b7b2c2172e38d0f7f57dd605a230a89a0 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Wed, 30 Jul 2014 17:32:24 +0200 Subject: Fix the main launch point to use asyncio correctly, and read stdin using it --- src/poezio.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/poezio.py b/src/poezio.py index 4c687b41..96445db2 100644 --- a/src/poezio.py +++ b/src/poezio.py @@ -12,7 +12,6 @@ Starting point of poezio. Launches both the Connection and Gui import sys import os -import asyncio import signal import logging @@ -57,17 +56,19 @@ def main(): if options.debug: cocore.debug = True cocore.start() + + # Warning: asyncio must always be imported after the config. Otherwise + # the asyncio logger will not follow our configuration and won't write + # the tracebacks in the correct file, etc + import asyncio + asyncio.get_event_loop().add_reader(sys.stdin, cocore.on_input_readable) + cocore.xmpp.start() + asyncio.get_event_loop().run_forever() + # We reach this point only when loop.stop() is called try: - if not cocore.xmpp.start(): # Connect to remote server - cocore.on_failed_connection() - except: - cocore.running = False cocore.reset_curses() - print("Poezio could not start, maybe you tried aborting it while it was starting?\n" - "If you think it is abnormal, please run it with the -d option and report the bug.") - else: - log.error('------------------------ new poezio start ------------------------') - cocore.main_loop() # Refresh the screen, wait for user events etc + except: + pass if __name__ == '__main__': main() -- cgit v1.2.3