Permalink
Browse files

Catch exceptions from cursor polling

This allows momoko to recover connections to a database if the db goes
down.
  • Loading branch information...
stevearc committed Sep 7, 2012
1 parent 29a6979 commit e4bbd17178a0c8f87284e0498c759173cdd7ab0d
Showing with 5 additions and 1 deletion.
  1. +5 −1 momoko/pools.py
View
@@ -322,7 +322,11 @@ def cursor(self, function, function_args, callback, cursor_kwargs={}):
self._ioloop.update_handler(self._fileno, IOLoop.READ)
def _io_callback(self, fd, events):
- state = self._conn.poll()
+ try:
+ state = self._conn.poll()
+ except psycopg2.OperationalError:
+ self.close()
+ return
if state == psycopg2.extensions.POLL_OK:
for callback in self._callbacks:

0 comments on commit e4bbd17

Please sign in to comment.