Skip to content

Commit

Permalink
Update psycopg2 to psycopg3
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Jan 14, 2025
1 parent b6f24a5 commit f5861b8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"default": env.db("DATABASE_URL"),
}
DATABASES["default"]["ATOMIC_REQUESTS"] = False
DATABASES["default"]["ENGINE"] = "django_db_geventpool.backends.postgresql_psycopg2"
DATABASES["default"]["ENGINE"] = "django_db_geventpool.backends.postgresql_psycopg3"
DATABASES["default"]["CONN_MAX_AGE"] = 0
DB_MAX_CONNS = env.int("DB_MAX_CONNS", default=50)
DATABASES["default"]["OPTIONS"] = {
Expand Down
13 changes: 3 additions & 10 deletions gunicorn_custom_workers.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import gevent
from gunicorn.workers.ggevent import GeventWorker
from psycogreen.gevent import patch_psycopg


class MyGeventWorker(GeventWorker):
def patch_psycopg2(self):
patch_psycopg()
self.log.info("Patched Psycopg2 for gevent")

def patch(self):
super().patch()
self.log.info("Patched all for gevent")
self.patch_psycopg2()

def handle_request(self, listener_name, req, sock, addr):
"""
Add timeout for Gunicorn requests
"""
try:
with gevent.Timeout(self.cfg.timeout):
super().handle_request(listener_name, req, sock, addr)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ packaging>=21.0
pika==1.3.2
pillow==11.0.0
psycogreen==1.0.2
psycopg2==2.9.10
psycopg[binary]==3.2.3
redis==5.2.1
requests==2.32.3
safe-eth-py[django]==6.1.0
Expand Down

0 comments on commit f5861b8

Please sign in to comment.