psycogreen
psycopg2 integration with coroutine libraries
What it is and what it does
psycogreen provides wait callbacks that hook psycopg2 into coroutine event loops, enabling non-blocking database queries within gevent and eventlet applications. It works by registering callbacks with psycopg2's extension API so that when a database operation would block, control returns to the event loop instead of freezing the thread.
The package offers two main modules: psycogreen.gevent for gevent integration and psycogreen.eventlet for eventlet integration. Each exposes a patch_psycopg() function and a corresponding wait callback. It is designed for applications that already use gevent or eventlet for concurrency and need their PostgreSQL queries to cooperate with that event loop rather than blocking.
Use it for:
- Run concurrent PostgreSQL queries in a gevent-based web application without blocking other greenlets.
- Integrate psycopg2 into an eventlet application that needs non-blocking database access alongside other async I/O.
- Avoid Eventlet's default monkeypatching by explicitly registering psycogreen's wait callback for finer control.
- Enable uWSGI green thread applications to execute asynchronous database operations within the async platform.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Integrates psycopg2 with coroutine libraries (eventlet, gevent) by registering wait callbacks that allow asynchronous database operations within a blocking interface.
Yes, if you are already committed to gevent or eventlet and need psycopg2 to cooperate with that event loop. No, if you are starting a new project—modern alternatives like asyncpg or psycopg3 with native async support are better choices. Caution: dormant maintenance (last release 2020) and source-only distribution mean you accept integration risk and potential compatibility issues with recent Python or psycopg2 versions.
Install
psycogreen on PyPI
pip
pip install psycogreenuv
uv add psycogreenpoetry
poetry add psycogreenInstalling psycogreen
Before you install
High install friction: source distribution only (psycogreen-1.0.2.tar.gz). Dormant maintenance—last release 2020-02-22, last commit 2023-12-04, no recent activity. Not actively maintained but repository remains open.
License in practice
BSD license (permissive). No restrictions on commercial or private use; you may modify and redistribute under the same license terms.
Quickstart
pip install psycogreen
import psycogreen.gevent
psycogreen.gevent.patch_psycopg()
# or
import psycogreen.eventlet
psycogreen.eventlet.patch_psycopg()
Requires psycopg2 to be installed separately. Requires either gevent or eventlet to be installed and active in your application.
Verify before relying
- Compatibility with modern psycopg2 versions (package has not been released since 2020)
- Whether gevent or eventlet monkey-patching approach is still the recommended pattern for async PostgreSQL in modern Python
- Python 3.10+ support status (classifiers list Python 2 and 3 generically)
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | dormant — 2,365 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,025,661/month — #4,480 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: psycogreen-1.0.2.tar.gz
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
django-db-geventpoolProvides a gevent-based connection pool for…
permissive · top 15,000 on PyPI
geventgevent provides lightweight concurrent…
permissive · top 1,000 on PyPI
eventletEventlet provides concurrent network…
permissive · top 5,000 on PyPI
greenletGreenlet provides lightweight coroutines for…
permissive · top 100 on PyPI
psycopgPsycopg 3 is a PostgreSQL database adapter for…
copyleft · top 1,000 on PyPI
aws-psycopg2Provides psycopg2 with statically linked…
permissive · top 5,000 on PyPI
psycopg2PostgreSQL database adapter for Python that…
copyleft · top 1,000 on PyPI
aiopgaiopg provides asyncio-based access to…
permissive · top 15,000 on PyPI
asynckivyAsyncKivy replaces Kivy's callback-based event…
permissive · top 15,000 on PyPI