summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-07-30 17:32:24 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-07-30 17:35:21 +0200
commitfe16d52b7b2c2172e38d0f7f57dd605a230a89a0 (patch)
tree7323a5bbc94d7b1af83d4d8e831ef498d34edd22 /src
parentc166e79a896eba0299f16f6f727febd225e62100 (diff)
downloadpoezio-fe16d52b7b2c2172e38d0f7f57dd605a230a89a0.tar.gz
poezio-fe16d52b7b2c2172e38d0f7f57dd605a230a89a0.tar.bz2
poezio-fe16d52b7b2c2172e38d0f7f57dd605a230a89a0.tar.xz
poezio-fe16d52b7b2c2172e38d0f7f57dd605a230a89a0.zip
Fix the main launch point to use asyncio correctly, and read stdin using it
Diffstat (limited to 'src')
-rw-r--r--src/poezio.py21
1 files 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()