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

Commit

Permalink
Catching IOError. Fixes #127
Browse files Browse the repository at this point in the history
Under heavy load we get "No such file or directory"
error when updating callbacks.

I've failed to reproduce it with the tcpproxy setup,
so this bugfix is currently not covered with unittest.
  • Loading branch information
haizaar committed Oct 25, 2015
1 parent 83ff0d0 commit de98f2f
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 de98f2f

Please sign in to comment.