Mercurial > xib
comparison bot.py @ 79:73a30fc1922b
Fixed the XMPP loop (release the lock)
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Sat, 05 Sep 2009 00:15:50 +0200 |
parents | a8749705fe94 |
children | bfa32b017fc9 |
comparison
equal
deleted
inserted
replaced
78:a8749705fe94 | 79:73a30fc1922b |
---|---|
74 | 74 |
75 def _xmpp_loop(self): | 75 def _xmpp_loop(self): |
76 """[Internal] XMPP infinite loop.""" | 76 """[Internal] XMPP infinite loop.""" |
77 i = 1 | 77 i = 1 |
78 while True: | 78 while True: |
79 unlock = False | |
79 try: | 80 try: |
80 if len(self.xmpp_connections) == 1: | 81 if len(self.xmpp_connections) == 1: |
81 sleep(0.5) # avoid bot connection being locked all the time | 82 sleep(0.5) # avoid bot connection being locked all the time |
82 j = 0 | 83 j = 0 |
83 for c in self.xmpp_connections.itervalues(): | 84 for c in self.xmpp_connections.itervalues(): |
97 i = 0 | 98 i = 0 |
98 except RuntimeError: | 99 except RuntimeError: |
99 pass | 100 pass |
100 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): | 101 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): |
101 self.error('=> Debug: invalid stanza', debug=True) | 102 self.error('=> Debug: invalid stanza', debug=True) |
103 unlock = True | |
102 except: | 104 except: |
103 self.error('[Error] Unkonwn exception on XMPP thread:') | 105 self.error('[Error] Unkonwn exception on XMPP thread:') |
104 traceback.print_exc() | 106 traceback.print_exc() |
107 unlock = True | |
108 if unlock == True: | |
109 c.lock.release() | |
105 | 110 |
106 | 111 |
107 def _xmpp_presence_handler(self, dispatcher, presence): | 112 def _xmpp_presence_handler(self, dispatcher, presence): |
108 """[Internal] Manage XMPP presence.""" | 113 """[Internal] Manage XMPP presence.""" |
109 | 114 |