You can clone with
Came across an opportunity to restart PostgreSQL and did so. My Tornado app ceased functioning and did not recover. Logs reveal the following exception:
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/tornado/web.py", line 1045, in wrapper
return method(self, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/tornado/gen.py", line 91, in wrapper
File "/usr/lib/python2.6/site-packages/tornado/gen.py", line 318, in run
File "/usr/lib/python2.6/site-packages/tornado/gen.py", line 207, in start
File "/usr/lib/python2.6/site-packages/momoko/clients.py", line 125, in execute
self._pool.new_cursor('execute', (operation, parameters), callback)
File "/usr/lib/python2.6/site-packages/momoko/pools.py", line 215, in new_cursor
cursor = connection.cursor()
File "/usr/lib/python2.6/site-packages/psycopg2/extras.py", line 116, in cursor
return _connection.cursor(self, cursor_factory=DictCursor)
InterfaceError: connection already closed
Given that Momoko maintains a pool of connections, catching and recovering from this in client code would be difficult.
#11: Try to recover from closed connections.
Can you try this commit?
It catches the exception, removes the closed connection and check if there is a new one. If there's no connection: create one. And if there is a connection: execute new_cursor again.
Did it work? Can I close this?
Sorry it took so long to respond. Yes, this appears to work fine. Thanks for the quick fix!