-
Notifications
You must be signed in to change notification settings - Fork 73
momoko doesn't reconnect #129
Comments
Are you running on mac by any chance? |
No, app is running on windows 8 and PostgreSQL is on Linux |
What is your usage scenario exactly? Do you
|
Yes, but actually I don't know what exactly is happening on postgres server side. For some reason it closes connection after some hours. So my scenario:
|
To clarify, are you saying always after restarting the program it starts working again? |
Yes. |
Please try your example on Linux. I would like to understand whether it's OS specific issue and I don't have access to Windows environment. Also please remove all of the code that is not essential to problem reproduction - like using |
Ok, I've found that problem occurs on windows after computer went to sleep mode. Also I've found that this code helps to reconnect. @Route(r"/test2")
class TestHandler2(BaseHandler):
@tornado.gen.coroutine
def get(self):
try:
cursor = yield self.db.execute("SELECT 1 as t;", cursor_factory=None)
self.write("SQL: %s<br>" % (repr(cursor.fetchall()),))
except Exception as error:
self.write(str(error))
try:
self.db.connect()
except Exception as error:
self.write(str(error))
self.finish() |
Great. If I were you I would submit a bug report to |
I use tornado (4.2.1) + momoko (2.2.1) + psycopg2 (2.6.1) for small web application and it works ok until PostgreSQL server close connection. Then after every db.execute() command I receive an OperationalError message:
Here is an app code:
I just can't understand where is a bug in momoko or in my app. How could I handle this exception and reconnect to db automatically without restarting app?
The text was updated successfully, but these errors were encountered: