{"id":21146,"library":"django-db-geventpool","title":"django-db-geventpool","description":"Provides a DB connection pool using gevent for Django, allowing concurrent database access in a gevent-ready manner. Current version 4.0.8, supports Django >= 4.2 and psycopg2/psycopg3. Release cadence is irregular.","status":"active","version":"4.0.8","language":"python","source_language":"en","source_url":"https://github.com/jneight/django-db-geventpool","tags":["django","gevent","connection-pool","postgresql","async"],"install":[{"cmd":"pip install django-db-geventpool","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for pool and monkey-patching","package":"gevent","optional":false},{"reason":"Framework integration","package":"django","optional":false},{"reason":"Default PostgreSQL driver","package":"psycopg2-binary","optional":true},{"reason":"Alternative PostgreSQL driver","package":"psycopg2","optional":true},{"reason":"PostgreSQL driver (psycopg3), supported from v4.0.3","package":"psycopg","optional":true}],"imports":[{"note":"In v4+, the backend is imported via Django's normal backend chain; the old direct import is deprecated.","wrong":"from django_db_geventpool.backends import postgresql_psycopg2","symbol":"DatabaseWrapper","correct":"from django.db.backends.postgresql import base as pg_base; then use pg_base.DatabaseWrapper"},{"note":"GEVENT_POOL is a shared global pool object; ensure it's imported correctly.","wrong":"","symbol":"GEVENT_POOL","correct":"from django_db_geventpool.utils import GEVENT_POOL"}],"quickstart":{"code":"import os\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')\nimport django\ndjango.setup()\n\nfrom django.db import connection\ncursor = connection.cursor()\ncursor.execute(\"SELECT 1\")\nprint(cursor.fetchone())\n# Ensure gevent is patched early; use gevent.monkey.patch_all() before importing django","lang":"python","description":"Basic usage: monkey-patch gevent early, then use Django ORM normally. Pool is automatically used if DATABASES configuration includes OPTIONS with pool settings."},"warnings":[{"fix":"Upgrade Django to >=4.2, and use django-db-geventpool >=4.0.8.","message":"Version 4.0.0 dropped support for Django < 3.1. Version 4.0.8 drops support for Django < 4.2. Upgrade your Django version if you're on an older release.","severity":"breaking","affected_versions":"<=4.0.0"},{"fix":"Place 'import gevent.monkey; gevent.monkey.patch_all()' as the very first lines of your application entry point (e.g., wsgi.py, manage.py).","message":"You must call gevent.monkey.patch_all() before importing any Django modules, including settings. Otherwise, database connections will not be patched and may deadlock.","severity":"gotcha","affected_versions":"all"},{"fix":"Use ENGINE as shown in the docs and set 'OPTIONS': {'psycopg3': True} in your DATABASES config.","message":"When using psycopg3 (psycopg package), ensure you set 'ENGINE': 'django_db_geventpool.backends.postgresql_psycopg2' even if using psycopg3. The pool backend is the same; psycopg3 support is enabled via the driver setting.","severity":"gotcha","affected_versions":">=4.0.3"},{"fix":"Configure DATABASES as documented, e.g. 'ENGINE': 'django_db_geventpool.backends.postgresql_psycopg2'.","message":"Direct import of backends from django_db_geventpool is deprecated. Use Django's default engine paths with custom OPTIONS instead.","severity":"deprecated","affected_versions":">=4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install django-db-geventpool' in your environment.","cause":"Package not installed or virtual environment not activated.","error":"ModuleNotFoundError: No module named 'django_db_geventpool'"},{"fix":"Ensure django-db-geventpool is installed and Django >=4.2.","cause":"Missing the required Django version or the package is not installed.","error":"django.core.exceptions.ImproperlyConfigured: 'django_db_geventpool.backends.postgresql_psycopg2' isn't an available database backend."},{"fix":"Patch gevent BEFORE importing psycopg2 or Django. Move 'import gevent.monkey; gevent.monkey.patch_all()' to the top.","cause":"gevent monkey-patching conflicts with psycopg2 when patched after psycopg2 is imported.","error":"AttributeError: module 'psycopg2' has no attribute 'extensions'"},{"fix":"Reduce pool size in DATABASES OPTIONS (e.g., 'MAX_CONNS': 10) and ensure connections are returned to pool (use context managers).","cause":"Default pool size too large or connections not correctly recycled, exhausting PostgreSQL max_connections.","error":"OperationalError: FATAL: remaining connection slots are reserved for non-replication superuser connections"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}