Mercurial > xib
comparison irclib.py @ 57:ebd4278e472f
Some thread safety for irclib.py
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Thu, 27 Aug 2009 22:33:25 +0200 |
parents | b048c4c03b00 |
children | 71508f22edb4 |
comparison
equal
deleted
inserted
replaced
56:b048c4c03b00 | 57:ebd4278e472f |
---|---|
189 """ | 189 """ |
190 for s in sockets: | 190 for s in sockets: |
191 for c in self.connections: | 191 for c in self.connections: |
192 if s == c._get_socket(): | 192 if s == c._get_socket(): |
193 c.lock.acquire() | 193 c.lock.acquire() |
194 c.process_data() | 194 if hasattr(c, 'socket'): |
195 c.process_data() | |
195 c.lock.release() | 196 c.lock.release() |
196 | 197 |
197 def process_timeout(self): | 198 def process_timeout(self): |
198 """Called when a timeout notification is due. | 199 """Called when a timeout notification is due. |
199 | 200 |
697 message -- Quit message. | 698 message -- Quit message. |
698 """ | 699 """ |
699 if not self.connected: | 700 if not self.connected: |
700 return | 701 return |
701 | 702 |
703 self.lock.acquire() | |
704 | |
702 self.connected = False | 705 self.connected = False |
703 | 706 |
704 self.quit(message) | 707 self.quit(message) |
705 | 708 |
706 try: | 709 try: |
707 self.socket.close() | 710 self.socket.close() |
708 except socket.error, x: | 711 except socket.error, x: |
709 pass | 712 pass |
710 self.socket = None | 713 self.socket = None |
714 self.lock.release() | |
711 self._handle_event(Event("disconnect", self.server, "", [message])) | 715 self._handle_event(Event("disconnect", self.server, "", [message])) |
712 | 716 |
713 def globops(self, text): | 717 def globops(self, text): |
714 """Send a GLOBOPS command.""" | 718 """Send a GLOBOPS command.""" |
715 self.send_raw("GLOBOPS :" + text) | 719 self.send_raw("GLOBOPS :" + text) |