Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AsyncPostgresDB initialization retry logic #440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fumoboy007
Copy link

@fumoboy007 fumoboy007 commented Sep 9, 2024

Bugs fixed:

  • Does not raise the exception when initialization fails.
  • Creates the connection pool multiple times even if it was already successful.

Fixes #439.

Copy link
Collaborator

@saikonen saikonen left a comment

Choose a reason for hiding this comment

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

Thank you for the bug report and fixes.

We can go forward with the current changes as well, but at a quick glance it seemed that this could've been fixed with a smaller diff as well. Could you make the changes I noted?

try:
self.pool = await aiopg.create_pool(db_conf.get_dsn(), timeout=db_conf.timeout)
break
Copy link
Collaborator

Choose a reason for hiding this comment

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

would it not have been sufficient to just add the break to the original code?

except Exception as e:
print("printing connection exception: " + str(e))
if retries - i < 1:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see this is never actually hit as range excludes the end, but can be fixed with a slight tweak f.ex.

if retries-(i+1) < 1:

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.

Bugs in the AsyncPostgresDB initialization retry logic
2 participants