[storm] Storm and MySQL in WSGI environment - MySQL server run away

Jamu Kakar jkakar at kakar.ca
Wed Jan 26 11:20:46 UTC 2011


Hi Steve,

On Wed, Jan 26, 2011 at 10:00 AM, Steve Kieu <msh.computing at gmail.com> wrote:
> Thanks for the answer.
>
> The problem is that when create a Store object, storm does not try to
> connect right away so no exception is thrown at that point. When there is a
> need, storm try to use the connection and fail. To handle it, I have to wrap
> many try: catch exception all over places and not quite sure where and it
> does not look good.

In most cases you need one try/except at the place where you
application starts processing the request.  Something like:

def receive_request_from_web_server(request, retries=3):
    try:
        handle_request(request)
    except DisconnectionError:
        if retries:
            # Probably want to sleep for a few seconds here, to give
            # the database a chance to recover
            receive_request_from_web_server(request, retries - 1)
        else:
            raise

def handle_request(request):
    # Application logic for the request

> Like a php mysql db, they just don't care, if connection goes away, they
> reconnect / make new connection automatically. That would be be nice

That's not really possible with transactions.  You need to start a new
transaction and perform your operation from scratch.

Thanks,
J.



More information about the storm mailing list