Commit 2695c0f3 authored by ale's avatar ale
Browse files

Fix the XMPP probe so that it actually fails on error

parent 31558dbf
Pipeline #7989 passed with stages
in 1 minute and 48 seconds
......@@ -19,13 +19,15 @@ def probe_xmpp(ctx):
def _timeout():
time.sleep(TIMEOUT)
if not done.isSet():
ctx.log('timeout')
bot.disconnect()
threading.Thread(target=_timeout, daemon=True).start()
try:
ctx.log('connecting to %s:5222', ctx['server'])
if bot.connect((ctx['server'], 5222), reattempt=False):
ctx.log('connection successful, setting presence')
ctx.log('connection successful')
# should run the _start callback here.
bot.process(block=True)
ctx.log('disconnected successfully')
else:
......@@ -33,3 +35,6 @@ def probe_xmpp(ctx):
finally:
done.set()
bot.disconnect()
if bot.error:
raise Exception('XMPP error: %s' % bot.error)
......@@ -11,12 +11,14 @@ class SendMsgBot(ClientXMPP):
self.reconnect_max_attempts = 0
self.session_timeout = 5
self.error = None
self.recipient = recipient
self.msg = msg
self.add_event_handler('session_start', self.start)
self.add_event_handler('stream_error', self._error)
self.add_event_handler('session_start', self._start)
def start(self, event):
def _start(self, event):
self.send_presence()
self.get_roster()
......@@ -25,5 +27,6 @@ class SendMsgBot(ClientXMPP):
self.disconnect()
def _error(self, event):
self.error = event
self.disconnect()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment