Mercurial > xib
comparison bot.py @ 101:29d3b85c6286
Minor fixes/improvements
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Fri, 20 Nov 2009 15:30:07 +0100 |
parents | 6289ac5a2db7 |
children | 23416c27b592 |
comparison
equal
deleted
inserted
replaced
100:6289ac5a2db7 | 101:29d3b85c6286 |
---|---|
81 while True: | 81 while True: |
82 unlock = False | 82 unlock = False |
83 try: | 83 try: |
84 if len(self.xmpp_connections) == 1: | 84 if len(self.xmpp_connections) == 1: |
85 sleep(0.5) # avoid bot connection being locked all the time | 85 sleep(0.5) # avoid bot connection being locked all the time |
86 j = 0 | 86 for j, c in enumerate(self.xmpp_connections.itervalues()): |
87 for c in self.xmpp_connections.itervalues(): | |
88 i += 1 | 87 i += 1 |
89 j += 1 | |
90 if hasattr(c, 'lock'): | 88 if hasattr(c, 'lock'): |
91 c.lock.acquire() | 89 c.lock.acquire() |
92 if i == j: | 90 if i == j: |
93 ping = xmpp.protocol.Iq(typ='get') | 91 ping = xmpp.protocol.Iq(typ='get') |
94 ping.addChild(name='ping', namespace='urn:xmpp:ping') | 92 ping.addChild(name='ping', namespace='urn:xmpp:ping') |
101 i = 0 | 99 i = 0 |
102 except RuntimeError: | 100 except RuntimeError: |
103 pass | 101 pass |
104 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): | 102 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): |
105 self.error('=> Debug: invalid stanza', debug=True) | 103 self.error('=> Debug: invalid stanza', debug=True) |
104 self.reopen_xmpp_connection(c) | |
106 unlock = True | 105 unlock = True |
107 except xmpp.Conflict: | 106 except xmpp.Conflict: |
107 self.error('=> Debug: conflict', debug=True) | |
108 self.reopen_xmpp_connection(c) | 108 self.reopen_xmpp_connection(c) |
109 unlock = True | 109 unlock = True |
110 except: | 110 except: |
111 error = '[Error] Unkonwn exception on XMPP thread:\n' | 111 error = '[Error] Unknown exception on XMPP thread:\n' |
112 error += traceback.format_exc() | 112 error += traceback.format_exc() |
113 self.error(error, send_to_admins=True) | 113 self.error(error, send_to_admins=True) |
114 unlock = True | 114 unlock = True |
115 if unlock == True: | 115 if unlock == True: |
116 c.lock.release() | 116 c.lock.release() |