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

Catching IOError. Fixes #127 #128

Merged
merged 1 commit into from
Oct 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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