Skip to content
Browse files

Catch exceptions from cursor polling

This allows momoko to recover connections to a database if the db goes
  • Loading branch information...
1 parent 29a6979 commit e4bbd17178a0c8f87284e0498c759173cdd7ab0d @stevearc stevearc committed
Showing with 5 additions and 1 deletion.
  1. +5 −1 momoko/
6 momoko/
@@ -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.
Something went wrong with that request. Please try again.