Skip to content

Conversation

@aigarius
Copy link

If connection to DB fails before we hand it off to the application, retry connecting to the DB a few times before failing

@meteozond
Copy link
Contributor

+1 Looks reasonable, are there any drawbacks for this PR?

@GitFree
Copy link

GitFree commented Mar 31, 2015

if MYSQLPOOL_RETRY = 5, it actually retried 6 times.

if connection:
return connection
else:
return get_pool().connect(**kwargs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here should raise exception instead of "trying again"

@variable
Copy link

variable commented Apr 27, 2016

I think it should be refactored into:

while(retry and not connection):
    try:
        connection = get_pool().connect(**kwargs)
    except:
        connection = None
        retry -= 1
        if not retry:
            raise
return connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants