Permalink
Browse files

Merge pull request #70 from lilydjwg/master

fix: a socket may be unregistered when not registered

Should fix #68
  • Loading branch information...
2 parents 5577843 + 45561b5 commit bb7efe2ded0a839ad4ff261f9855c026097cdf72 @Jajcus committed Feb 21, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 pyxmpp2/mainloop/poll.py
View
@@ -63,7 +63,12 @@ def _configure_io_handler(self, handler):
fileno = handler.fileno()
if old_fileno is not None and fileno != old_fileno:
del self._handlers[old_fileno]
- self.poll.unregister(old_fileno)
+ try:
+ self.poll.unregister(old_fileno)
+ except KeyError:
+ # The socket has changed, but the old one isn't registered,
+ # e.g. ``prepare`` wants to connect again
+ pass
if not prepared:
self._unprepared_handlers[handler] = fileno
if not fileno:

0 comments on commit bb7efe2

Please sign in to comment.