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.
.. _psycogreen: https://github.com/psycopg/psycogreen
.. _Psycopg: http://initd.org/psycopg/
.. __: http://initd.org/psycopg/docs/advanced.html#support-to-coroutine-libraries
.. __: http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.set_wait_callback
Installation
------------
``pip install psycogreen``
Module ``psycogreen.eventlet``
------------------------------
`Eventlet`_ currently supports Psycopg out-of-the-box and ``psycogreen`` is not
necessary. See `the documentation`__ for patching instruction.
.. _Eventlet: http://eventlet.net/
.. __: http://eventlet.net/doc/patching.html#monkeypatching-the-standard-library
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|__.
.. |tests/test_eventlet.py| replace:: ``tests/test_eventlet.py``
.. __: https://github.com/psycopg/psycogreen/blob/master/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|__.
.. _gevent: http://www.gevent.org/
.. |tests/test_gevent.py| replace:: ``tests/test_gevent.py``
.. __: https://github.com/psycopg/psycogreen/blob/master/tests/test_gevent.py
uWSGI green threads
-------------------
Roberto De Ioris is writing uGreen__, a green thread implementation on top of
the `uWSGI async platform`__.
.. __: http://projects.unbit.it/uwsgi/wiki/uGreen
.. __: http://projects.unbit.it/uwsgi/
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.
.. __: http://projects.unbit.it/uwsgi/browser/tests/psycopg2_green.py
.. __: http://projects.unbit.it/uwsgi/browser/tests/psycogreen_green.py
Raw data
{
"_id": null,
"home_page": "https://github.com/psycopg/psycogreen/",
"name": "psycogreen",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Daniele Varrazzo",
"author_email": "daniele.varrazzo@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/eb/72/4a7965cf54e341006ad74cdc72cd6572c789bc4f4e3fadc78672f1fbcfbd/psycogreen-1.0.2.tar.gz",
"platform": "",
"description": "psycogreen -- psycopg2 integration with coroutine libraries\n===========================================================\n\nThe `psycogreen`_ package enables psycopg2 to work with coroutine libraries,\nusing asynchronous calls internally but offering a blocking interface so that\nregular code can run unmodified.\n\n`Psycopg`_ offers `coroutines support`__ since release 2.2. Because the main\nmodule is a C extension it cannot be monkey-patched to become\ncoroutine-friendly. Instead it exposes `a hook`__ that coroutine libraries can\nuse to install a function integrating with their event scheduler. Psycopg will\ncall the function whenever it executes a libpq call that may block.\n`psycogreen` is a collection of \"wait callbacks\" useful to integrate Psycopg\nwith different coroutine libraries.\n\n.. _psycogreen: https://github.com/psycopg/psycogreen\n.. _Psycopg: http://initd.org/psycopg/\n.. __: http://initd.org/psycopg/docs/advanced.html#support-to-coroutine-libraries\n.. __: http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.set_wait_callback\n\n\nInstallation\n------------\n\n``pip install psycogreen``\n\n\nModule ``psycogreen.eventlet``\n------------------------------\n\n`Eventlet`_ currently supports Psycopg out-of-the-box and ``psycogreen`` is not\nnecessary. See `the documentation`__ for patching instruction.\n\n.. _Eventlet: http://eventlet.net/\n.. __: http://eventlet.net/doc/patching.html#monkeypatching-the-standard-library\n\nIf for any reason you want to avoid using Eventlet monkeypatching you can use\n``psycogreen.eventlet.patch_psycopg()``.\n\nFunction ``psycogreen.eventlet.patch_psycopg()``\n Enable async processing in Psycopg integrated with the Eventlet events\n loop. It is performed by registering ``eventlet_wait_callback()`` as\n psycopg2 wait callback.\n\nFunction ``psycogreen.eventlet.eventlet_wait_callback(conn)``\n A wait callback integrating with Eventlet events loop.\n\nAn example script showing concurrent usage of ``psycopg2`` with ``urlopen()``\nwith Eventlet is available in |tests/test_eventlet.py|__.\n\n.. |tests/test_eventlet.py| replace:: ``tests/test_eventlet.py``\n.. __: https://github.com/psycopg/psycogreen/blob/master/tests/test_eventlet.py\n\n\nModule ``psycogreen.gevent``\n----------------------------\n\nIn order to use psycopg2 asynchronously with `gevent`_ you can use\n``psycogreen.gevent.patch_psycopg()``.\n\nFunction ``psycogreen.gevent.patch_psycopg()``\n Enable async processing in Psycopg integrated with the gevent events\n loop. It is performed by registering ``gevent_wait_callback()`` as\n psycopg2 wait callback.\n\nFunction ``psycogreen.gevent.gevent_wait_callback(conn)``\n A wait callback integrating with gevent events loop.\n\nAn example script showing concurrent usage of ``psycopg2`` with ``urlopen()``\nwith gevent is available in |tests/test_gevent.py|__.\n\n.. _gevent: http://www.gevent.org/\n.. |tests/test_gevent.py| replace:: ``tests/test_gevent.py``\n.. __: https://github.com/psycopg/psycogreen/blob/master/tests/test_gevent.py\n\n\nuWSGI green threads\n-------------------\n\nRoberto De Ioris is writing uGreen__, a green thread implementation on top of\nthe `uWSGI async platform`__.\n\n.. __: http://projects.unbit.it/uwsgi/wiki/uGreen\n.. __: http://projects.unbit.it/uwsgi/\n\nHe has performed some tests using both `psycopg2 async support`__ and\n`psycopg2 green support`__ and has reported no problem in their stress tests\nwith both the async styles.\n\n.. __: http://projects.unbit.it/uwsgi/browser/tests/psycopg2_green.py\n.. __: http://projects.unbit.it/uwsgi/browser/tests/psycogreen_green.py",
"bugtrack_url": null,
"license": "BSD",
"summary": "psycopg2 integration with coroutine libraries",
"version": "1.0.2",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "4f6f68ba5ffb1d6908160de3dacd3618",
"sha256": "c429845a8a49cf2f76b71265008760bcd7c7c77d80b806db4dc81116dbcd130d"
},
"downloads": -1,
"filename": "psycogreen-1.0.2.tar.gz",
"has_sig": true,
"md5_digest": "4f6f68ba5ffb1d6908160de3dacd3618",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5411,
"upload_time": "2020-02-22T19:55:22",
"upload_time_iso_8601": "2020-02-22T19:55:22.020770Z",
"url": "https://files.pythonhosted.org/packages/eb/72/4a7965cf54e341006ad74cdc72cd6572c789bc4f4e3fadc78672f1fbcfbd/psycogreen-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-02-22 19:55:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "psycopg",
"github_project": "psycogreen",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "psycogreen"
}