Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Catch exceptions from cursor polling

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