Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #128 from haizaar/master
Browse files Browse the repository at this point in the history
Catching IOError. Fixes #127
  • Loading branch information
haizaar committed Oct 26, 2015
2 parents 5f50a14 + de98f2f commit 37c7775
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions momoko/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,21 @@ def _io_callback(self, future, result, fd=None, events=None):
self.ioloop.remove_handler(self.fileno)
future.set_exc_info(sys.exc_info())
else:
if state == POLL_OK:
try:
if state == POLL_OK:
self.ioloop.remove_handler(self.fileno)
future.set_result(result)
elif state == POLL_READ:
self.ioloop.update_handler(self.fileno, IOLoop.READ)
elif state == POLL_WRITE:
self.ioloop.update_handler(self.fileno, IOLoop.WRITE)
else:
future.set_exception(psycopg2.OperationalError("poll() returned %s" % state))
except IOError:
# Can happen when there are quite a lof of outstanding
# requests. See https://github.com/FSX/momoko/issues/127
self.ioloop.remove_handler(self.fileno)
future.set_result(result)
elif state == POLL_READ:
self.ioloop.update_handler(self.fileno, IOLoop.READ)
elif state == POLL_WRITE:
self.ioloop.update_handler(self.fileno, IOLoop.WRITE)
else:
future.set_exception(psycopg2.OperationalError("poll() returned %s" % state))
future.set_exception(psycopg2.OperationalError("IOError on socker"))

def ping(self):
"""
Expand Down

0 comments on commit 37c7775

Please sign in to comment.