Skip to content

feat: add pool options recycle #3080

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

Merged
merged 1 commit into from
May 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/smartdoc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def get_db_setting(self) -> dict:
"ENGINE": self.get('DB_ENGINE'),
"POOL_OPTIONS": {
"POOL_SIZE": 20,
"MAX_OVERFLOW": int(self.get('DB_MAX_OVERFLOW'))
"MAX_OVERFLOW": int(self.get('DB_MAX_OVERFLOW')),
'RECYCLE': 30 * 60
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code appears to be functioning correctly without apparent issues. However, it can be optimized slightly:

@@ -114,7 +114,8 @@ def get_db_setting(self) -> dict:
             "ENGINE": self.get('DB_ENGINE'),
             "POOL_OPTIONS": {
                 "POOL_SIZE": 20,
-                "MAX_OVERFLOW": int(self.get('DB_MAX_OVERFLOW'))
+                "MAX_OVERFLOW": int(self.get('DB_MAX_OVERFLOW')) if self.get('DB_MAX_OVERFLOW') else None,
+                'RECYCLE': 30 * 60
             }
         }

Optimizations Made:

  1. Default Value Handling: Added a check using an if statement to set the MAX_OVERFLOW value to None if it is not found in the configuration, preventing unnecessary conversion attempts (int(None)).

This change ensures that any missing or empty DB_MAX_OVERFLOW configuration values will gracefully handle this scenario without raising exceptions when converting them to integers.

Expand Down