Open
Description
Python:
- 2.7.11
Libraries:
- Tornado = 4.3
- MotorEngine = 0.9.0
I'm doing some tests with this library and something that i can't handle is when i'm trying to do any request to MongoDB when it's down.
This warning is shown on the console:
[W 160714 09:55:26 iostream:1186] Connect error on fd 14: ECONNREFUSED
When this message appears in a few seconds the RAM is overloaded blocking the computer and i just must wait to try to kill the process.
Im triying to handle this when i instanciate the connection:
io_loop = tornado.ioloop.IOLoop.instance()
try:
mongo_connection = connect("apitest", io_loop=io_loop)
print dir(mongo_connection)
print type(mongo_connection)
print mongo_connection.connection
print mongo_connection.previous_error().result
except ConnectionError as err:
print err.message
except Exception as err:
print err.message
application_apiEngine = tornado.web.Application(routes)
application_apiEngine.listen(options.port)
io_loop.start()
and also in the callback when i create a document:
@gen.coroutine
def create(self, data):
doc = Doc(data)
try:
result = doc.save()
except Exception as err:
print 'i'm Error'
raise gen.Return(False)
else:
raise gen.Return(True)
I just want to be sure if in some case the connection is lost i will get a feedback for just send some error messge in my service.
Metadata
Metadata
Assignees
Labels
No labels