METADATA 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. Metadata-Version: 2.1
  2. Name: psycogreen
  3. Version: 1.0.2
  4. Summary: psycopg2 integration with coroutine libraries
  5. Home-page: https://github.com/psycopg/psycogreen/
  6. Author: Daniele Varrazzo
  7. Author-email: daniele.varrazzo@gmail.com
  8. License: BSD
  9. Project-URL: Bug tracker, https://github.com/psycopg/psycogreen/issues
  10. Project-URL: Funding, https://github.com/sponsors/dvarrazzo
  11. Platform: UNKNOWN
  12. Classifier: Development Status :: 5 - Production/Stable
  13. Classifier: License :: OSI Approved :: BSD License
  14. Classifier: Operating System :: OS Independent
  15. Classifier: Programming Language :: Python :: 2
  16. Classifier: Programming Language :: Python :: 3
  17. Classifier: Topic :: Database
  18. psycogreen -- psycopg2 integration with coroutine libraries
  19. ===========================================================
  20. The `psycogreen`_ package enables psycopg2 to work with coroutine libraries,
  21. using asynchronous calls internally but offering a blocking interface so that
  22. regular code can run unmodified.
  23. `Psycopg`_ offers `coroutines support`__ since release 2.2. Because the main
  24. module is a C extension it cannot be monkey-patched to become
  25. coroutine-friendly. Instead it exposes `a hook`__ that coroutine libraries can
  26. use to install a function integrating with their event scheduler. Psycopg will
  27. call the function whenever it executes a libpq call that may block.
  28. `psycogreen` is a collection of "wait callbacks" useful to integrate Psycopg
  29. with different coroutine libraries.
  30. .. _psycogreen: https://github.com/psycopg/psycogreen
  31. .. _Psycopg: http://initd.org/psycopg/
  32. .. __: http://initd.org/psycopg/docs/advanced.html#support-to-coroutine-libraries
  33. .. __: http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.set_wait_callback
  34. Installation
  35. ------------
  36. ``pip install psycogreen``
  37. Module ``psycogreen.eventlet``
  38. ------------------------------
  39. `Eventlet`_ currently supports Psycopg out-of-the-box and ``psycogreen`` is not
  40. necessary. See `the documentation`__ for patching instruction.
  41. .. _Eventlet: http://eventlet.net/
  42. .. __: http://eventlet.net/doc/patching.html#monkeypatching-the-standard-library
  43. If for any reason you want to avoid using Eventlet monkeypatching you can use
  44. ``psycogreen.eventlet.patch_psycopg()``.
  45. Function ``psycogreen.eventlet.patch_psycopg()``
  46. Enable async processing in Psycopg integrated with the Eventlet events
  47. loop. It is performed by registering ``eventlet_wait_callback()`` as
  48. psycopg2 wait callback.
  49. Function ``psycogreen.eventlet.eventlet_wait_callback(conn)``
  50. A wait callback integrating with Eventlet events loop.
  51. An example script showing concurrent usage of ``psycopg2`` with ``urlopen()``
  52. with Eventlet is available in |tests/test_eventlet.py|__.
  53. .. |tests/test_eventlet.py| replace:: ``tests/test_eventlet.py``
  54. .. __: https://github.com/psycopg/psycogreen/blob/master/tests/test_eventlet.py
  55. Module ``psycogreen.gevent``
  56. ----------------------------
  57. In order to use psycopg2 asynchronously with `gevent`_ you can use
  58. ``psycogreen.gevent.patch_psycopg()``.
  59. Function ``psycogreen.gevent.patch_psycopg()``
  60. Enable async processing in Psycopg integrated with the gevent events
  61. loop. It is performed by registering ``gevent_wait_callback()`` as
  62. psycopg2 wait callback.
  63. Function ``psycogreen.gevent.gevent_wait_callback(conn)``
  64. A wait callback integrating with gevent events loop.
  65. An example script showing concurrent usage of ``psycopg2`` with ``urlopen()``
  66. with gevent is available in |tests/test_gevent.py|__.
  67. .. _gevent: http://www.gevent.org/
  68. .. |tests/test_gevent.py| replace:: ``tests/test_gevent.py``
  69. .. __: https://github.com/psycopg/psycogreen/blob/master/tests/test_gevent.py
  70. uWSGI green threads
  71. -------------------
  72. Roberto De Ioris is writing uGreen__, a green thread implementation on top of
  73. the `uWSGI async platform`__.
  74. .. __: http://projects.unbit.it/uwsgi/wiki/uGreen
  75. .. __: http://projects.unbit.it/uwsgi/
  76. He has performed some tests using both `psycopg2 async support`__ and
  77. `psycopg2 green support`__ and has reported no problem in their stress tests
  78. with both the async styles.
  79. .. __: http://projects.unbit.it/uwsgi/browser/tests/psycopg2_green.py
  80. .. __: http://projects.unbit.it/uwsgi/browser/tests/psycogreen_green.py