8000 Not raising any Exception when there is not connection · Issue #122 · heynemann/motorengine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Not raising any Exception when there is not connection #122
Open
@rubenbonilla

Description

@rubenbonilla

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0