Mercurial > xib
comparison bot.py @ 44:3d964ca1cf89
Fixed XMPP infinite loop and a debug message that wasn't flagged as a debug one.
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Mon, 24 Aug 2009 19:47:18 +0200 |
parents | b8c9ddf320f8 |
children | 41394ddb3aff |
comparison
equal
deleted
inserted
replaced
43:9f72353e4064 | 44:3d964ca1cf89 |
---|---|
75 try: | 75 try: |
76 try: | 76 try: |
77 if len(self.xmpp_connections) == 1: | 77 if len(self.xmpp_connections) == 1: |
78 sleep(0.5) # avoid bot connection being locked all the time | 78 sleep(0.5) # avoid bot connection being locked all the time |
79 for c in self.xmpp_connections.itervalues(): | 79 for c in self.xmpp_connections.itervalues(): |
80 if hasattr(c, 'Process'): | 80 if hasattr(c, 'Process') and c.lock.acquire(blocking=False) == True: |
81 c.lock.acquire() | 81 c.lock.acquire() |
82 c.Process(0.5) | 82 c.Process(0.5) |
83 c.lock.release() | 83 c.lock.release() |
84 else: | |
85 sleep(0.5) | |
86 except RuntimeError: | 84 except RuntimeError: |
87 pass | 85 pass |
88 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): | 86 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed): |
89 self.error('=> Debug: received invalid stanza', debug=True) | 87 self.error('=> Debug: received invalid stanza', debug=True) |
90 continue | 88 continue |
313 # From here we skip if the event was not received on bot connection | 311 # From here we skip if the event was not received on bot connection |
314 if connection.get_nickname() != self.nickname: | 312 if connection.get_nickname() != self.nickname: |
315 self.error('=> Debug: ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True) | 313 self.error('=> Debug: ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True) |
316 continue | 314 continue |
317 | 315 |
318 | |
319 # Leaving events | 316 # Leaving events |
320 if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target() == bridge.irc_room: | 317 if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target() == bridge.irc_room: |
321 if len(event.arguments()) > 0: | 318 if len(event.arguments()) > 0: |
322 leave_message = event.arguments()[0] | 319 leave_message = event.arguments()[0] |
323 elif event.eventtype() == 'quit': | 320 elif event.eventtype() == 'quit': |
351 continue | 348 continue |
352 | 349 |
353 if handled == False: | 350 if handled == False: |
354 if not event.eventtype() in ['quit', 'part', 'nick']: | 351 if not event.eventtype() in ['quit', 'part', 'nick']: |
355 self.error(event_str, debug=True) | 352 self.error(event_str, debug=True) |
356 self.error('=> Debug: event was not handled') | 353 self.error('=> Debug: event was not handled', debug=True) |
357 return | 354 return |
358 | 355 |
359 | 356 |
360 if event.eventtype() in ['namreply', 'join']: | 357 if event.eventtype() in ['namreply', 'join']: |
361 if connection.get_nickname() != self.nickname: | 358 if connection.get_nickname() != self.nickname: |