diff --git a/config/settings/base.py b/config/settings/base.py index 9a53c3466..2cb72e950 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -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"] = { diff --git a/gunicorn_custom_workers.py b/gunicorn_custom_workers.py index 11d3c5295..afdf31175 100644 --- a/gunicorn_custom_workers.py +++ b/gunicorn_custom_workers.py @@ -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) diff --git a/requirements.txt b/requirements.txt index a94babca6..5a70921d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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