Skip to content

Commit

Permalink
adding connection params for to prevent failed connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Marty Bode committed Feb 27, 2024
1 parent 7cc573f commit 5fc1510
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion middleware/initialize_psycopg2_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ def initialize_psycopg2_connection():
try:
DO_DATABASE_URL = os.getenv("DO_DATABASE_URL")

return psycopg2.connect(DO_DATABASE_URL)
return psycopg2.connect(
DO_DATABASE_URL,
keepalives=1,
keepalives_idle=30,
keepalives_interval=10,
keepalives_count=5,
)

except:
print("Error while initializing the DigitalOcean client with psycopg2.")
Expand Down

0 comments on commit 5fc1510

Please sign in to comment.