psycogreen – psycopg2 integration with coroutine libraries
The psycogreen package enables psycopg2 to work with coroutine libraries, using asynchronous calls internally but offering a blocking interface so that regular code can run unmodified.
Psycopg offers coroutines support since release 2.2. Because the main module is a C extension it cannot be monkey-patched to become coroutine-friendly. Instead it exposes a hook that coroutine libraries can use to install a function integrating with their event scheduler. Psycopg will call the function whenever it executes a libpq call that may block. psycogreen is a collection of “wait callbacks” useful to integrate Psycopg with different coroutine libraries.
Module psycogreen.eventlet
Eventlet currently supports Psycopg out-of-the-box and psycogreen is not necessary. See the documentation for patching instruction.
If for any reason you want to avoid using Eventlet monkeypatching you can use psycogreen.eventlet.patch_psycopg().
- Function psycogreen.eventlet.patch_psycopg()
Enable async processing in Psycopg integrated with the Eventlet events loop. It is performed by registering eventlet_wait_callback() as psycopg2 wait callback.
- Function psycogreen.eventlet.eventlet_wait_callback(conn)
A wait callback integrating with Eventlet events loop.
An example script showing concurrent usage of psycopg2 with urlopen() with Eventlet is available in tests/test_eventlet.py.
Module psycogreen.gevent
In order to use psycopg2 asynchronously with gevent you can use psycogreen.gevent.patch_psycopg().
- Function psycogreen.gevent.patch_psycopg()
Enable async processing in Psycopg integrated with the gevent events loop. It is performed by registering gevent_wait_callback() as psycopg2 wait callback.
- Function psycogreen.gevent.gevent_wait_callback(conn)
A wait callback integrating with gevent events loop.
An example script showing concurrent usage of psycopg2 with urlopen() with gevent is available in tests/test_gevent.py.
uWSGI green threads
Roberto De Ioris is writing uGreen, a green thread implementation on top of the uWSGI async platform.
He has performed some tests using both psycopg2 async support and psycopg2 green support and has reported no problem in their stress tests with both the async styles.
Metadata
Release files for psycogreen 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| psycogreen-1.0.tar.gz | 5.1 kB | Without provenance | Details |
Release files / psycogreen-1.0.tar.gz
| Download URL | psycogreen-1.0.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9acfa6cb5373bcf1eaf27c904d98d59c9f3bb0065cbb005f83ccc45055ace9a1
|
|
BLAKE2b-256 checksum How to use checksums |
66299250c6a11822f56a1c2f703e4031d173c5b3725095d3422c11cafcc5427f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for psycogreen 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.