Mercurial > xib
comparison bot.py @ 42:b8c9ddf320f8
Thread safety for bot.close_xmpp_connection().
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Mon, 24 Aug 2009 18:06:37 +0200 |
parents | 4c4f4ee72e17 |
children | 3d964ca1cf89 |
comparison
equal
deleted
inserted
replaced
41:4c4f4ee72e17 | 42:b8c9ddf320f8 |
---|---|
452 | 452 |
453 def close_xmpp_connection(self, nickname): | 453 def close_xmpp_connection(self, nickname): |
454 if not self.xmpp_connections.has_key(nickname): | 454 if not self.xmpp_connections.has_key(nickname): |
455 return | 455 return |
456 c = self.xmpp_connections[nickname] | 456 c = self.xmpp_connections[nickname] |
457 c.lock.acquire() | |
457 c.used_by -= 1 | 458 c.used_by -= 1 |
458 if c.used_by < 1: | 459 if c.used_by < 1: |
459 self.error('===> Debug: closing XMPP connection for "'+nickname+'"', debug=True) | 460 self.error('===> Debug: closing XMPP connection for "'+nickname+'"', debug=True) |
460 self.xmpp_connections.pop(nickname) | 461 self.xmpp_connections.pop(nickname) |
461 del c | 462 del c |
462 else: | 463 else: |
464 c.lock.release() | |
463 self.error('===> Debug: XMPP connection for "'+nickname+'" is now used by '+str(c.used_by)+' bridges', debug=True) | 465 self.error('===> Debug: XMPP connection for "'+nickname+'" is now used by '+str(c.used_by)+' bridges', debug=True) |
464 | 466 |
465 | 467 |
466 def removeBridge(self, bridge): | 468 def removeBridge(self, bridge): |
467 self.bridges.remove(bridge) | 469 self.bridges.remove(bridge) |