Permalink
Browse files

Example 22: Proactively deal with a couple of connection problems tha…

…t we know will come up from our earlier testing.

This code is still not being called, but it will be in a second.
  • Loading branch information...
1 parent 62a9a88 commit faba7c72cc84e39aafab48001384755c5f82ef64 @buchuki committed Jul 5, 2013
Showing with 5 additions and 1 deletion.
  1. +5 −1 orkiv/__main__.py
View
6 orkiv/__main__.py
@@ -2,6 +2,7 @@
from kivy.uix.anchorlayout import AnchorLayout
from kivy.properties import ObjectProperty
from sleekxmpp import ClientXMPP
+from sleekxmpp.exceptions import XMPPError
from kivy.uix.textinput import TextInput
from kivy.uix.modalview import ModalView
from kivy.uix.label import Label
@@ -45,7 +46,10 @@ class Orkiv(App):
def connect_to_jabber(self, jabber_id, password):
self.xmpp = ClientXMPP(jabber_id, password)
- self.xmpp.connect()
+ self.xmpp.reconnect_max_attempts = 1
+ connected = self.xmpp.connect()
+ if not connected:
+ raise XMPPError("unable to connect")
self.xmpp.process()
self.xmpp.send_presence()
self.xmpp.get_roster()

0 comments on commit faba7c7

Please sign in to comment.