{ "info": { "author": "Erick Ponce Le\u00e3o", "author_email": "erickponceleao@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": "django-geventpool\n====================\n\n.. image:: https://img.shields.io/pypi/v/django-db-geventpool.svg\n :target: https://pypi.python.org/pypi/django-geventpool\n :alt: pypi version\n\n.. image:: http://img.shields.io/pypi/l/django-db-geventpool.svg\n :target: https://github.com/erickponce/django-db-geventpool\n :alt: pypi license\n\nAnother DB pool using gevent for PostgreSQL DB (based on django-db-geventpool).\n\n*Need Django 1.5.x or newer (check settings for django >= 1.6)*\n\nPython 3 is supported, but if `gevent` is not installed successfully it will use `eventlet`.\n\n\nPatch psycopg2\n--------------\n\nBefore using the pool, psycopg2 must be patched with psycogreen, if you are using `gunicorn webserver `_,\na good place is the `post_fork() `_ function at the config file:\n\n.. code:: python\n\n from psycogreen.gevent import patch_psycopg # use this if you use gevent workers\n from psycogreen.eventlet import patch_psycopg # use this if you use eventlet workers\n\n def post_fork(server, worker):\n patch_psycopg()\n worker.log.info(\"Made Psycopg2 Green\")\n\n\nSettings\n---------\n\n\n + Set *ENGINE* in your database settings to: \n + *'django_geventpool.backends.postgresql_psycopg2'*\n + For postgis: *'django_geventpool.backends.postgis'*\n + Add *MAX_CONNS* to *OPTIONS* to set the maximun number of connections allowed to database (default=4)\n + If using django 1.6 or newer, add *'CONN_MAX_AGE': 0* to settings to disable default django persistent connection feature. And read below note if you are manually spawning greenlets \n\n.. code:: python\n\n # for django 1.5.x\n DATABASES = {\n 'default': {\n 'ENGINE': 'django_geventpool.backends.postgresql_psycopg2',\n 'NAME': 'db', # Or path to database file if using sqlite3.\n 'USER': 'postgres', # Not used with sqlite3.\n 'PASSWORD': 'postgres', # Not used with sqlite3.\n 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.\n 'PORT': '', # Set to empty string for default. Not used with sqlite3.\n 'OPTIONS': {\n 'MAX_CONNS': 30, # Set max allowed connections\n 'CONN_IDLE_TIMEOUT': 60, # Set to auto close idling connections\n 'CONN_WAIT_TIMEOUT': 15, # Set timeout when waiting for connections\n 'ON_RELEASE_DISCARD_ALL': False # Set True to run DISCARD_ALL when releasing connections\n }\n }\n }\n\n # for django 1.6 and newer version, CONN_MAX_AGE must be set to 0, or connections will never go back to the pool\n DATABASES = {\n 'default': {\n 'ENGINE': 'django_geventpool.backends.postgresql_psycopg2',\n 'NAME': 'db',\n 'USER': 'postgres',\n 'PASSWORD': 'postgres',\n 'HOST': '',\n 'PORT': '',\n 'ATOMIC_REQUESTS': False,\n 'CONN_MAX_AGE': 0,\n 'OPTIONS': {\n 'MAX_CONNS': 30, # Set max allowed connections\n 'CONN_IDLE_TIMEOUT': 60, # Set to auto close idling connections\n 'CONN_WAIT_TIMEOUT': 15, # Set timeout when waiting for connections\n 'ON_RELEASE_DISCARD_ALL': False # Set True to run DISCARD_ALL when releasing connections\n }\n }\n }\n\nUsing Django 1.6+ ORM when not serving requests\n____________\n\nIf you are using django 1.6+ with celery (or other), or have code that manually spawn greenlets it will not be sufficient to set CONN_MAX_AGE to 0.\nDjango only checks for long-live connections when finishing a request - So if you manually spawn a greenlet (or have a task spawning one) its connections will\nnot get cleaned up and will live until timeout. In production this can cause quite some open connections and while developing it can hamper your tests cases.\n\nTo solve it make sure that each greenlet either sends the django.core.signals.request_finished signal or calls django.db.close_old_connections() right before it ends\n\nThe decorator method is preferred, but the other alternatives are also valid.\n\n.. code:: python\n\n from django_db_geventpool.utils import close_connection\n\n @close_connection\n def greenlet_worker()\n ...\n\nor \n\n.. code:: python\n\n from django.core.signals import request_finished\n def greenlet_worker():\n ...\n request_finished.send(sender=\"greenlet\")\n\nor\n\n.. code:: python\n\n from django.db import close_old_connections\n def greenlet_worker():\n ...\n close_old_connections()\n\n\nOther pools\n------------\n\n* `django-db-pool `_\n* `django-postgresql `_", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/erickponce/django-db-geventpool", "keywords": null, "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "django-geventpool", "package_url": "https://pypi.org/project/django-geventpool/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-geventpool/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/erickponce/django-db-geventpool" }, "release_url": "https://pypi.org/project/django-geventpool/1.2.2/", "requires_dist": null, "requires_python": null, "summary": "Add a DB connection pool using gevent to django (based on django-db-geventpool)", "version": "1.2.2" }, "last_serial": 2024986, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "83c8f89f9c1ee51af23b0136e67f1850", "sha256": "0a7e0505e0d2f94ef9fab3326dd06ee4485daa64533bf1137e758b081b4d5d06" }, "downloads": -1, "filename": "django-geventpool-1.0.tar.gz", "has_sig": false, "md5_digest": "83c8f89f9c1ee51af23b0136e67f1850", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11731, "upload_time": "2016-03-18T18:20:11", "url": "https://files.pythonhosted.org/packages/cd/db/3aca7c6970bd59dec1cdb27f0b3f0e1bc1594ed2d403382701b1eab2dc06/django-geventpool-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "f6c94b61504c17071831d410b4cf6b0a", "sha256": "e3cca7f07c35ea8d6460b930d56eb583b88dcac6d0614c2ba5562d17db4d11ea" }, "downloads": -1, "filename": "django-geventpool-1.1.tar.gz", "has_sig": false, "md5_digest": "f6c94b61504c17071831d410b4cf6b0a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11779, "upload_time": "2016-03-18T18:34:29", "url": "https://files.pythonhosted.org/packages/20/21/34ea386d5ef320b817cf32dbea1d6e03a2441f7d5af41943ce7dd013e37c/django-geventpool-1.1.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "839e2e76f58cbf7d97ff9776b0d45b8d", "sha256": "9e73ccb29b94a92d56ca0c3ea045efbe0dc031d80095424b434981d7efa30ac2" }, "downloads": -1, "filename": "django-geventpool-1.1.1.tar.gz", "has_sig": false, "md5_digest": "839e2e76f58cbf7d97ff9776b0d45b8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11785, "upload_time": "2016-03-18T18:40:56", "url": "https://files.pythonhosted.org/packages/44/12/4f27e1cd71cc153b97f7c9851592343210cd8dfb7cac6d0b389eb743ef26/django-geventpool-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "c85d2dbe9537820c8ecf2fb7e185c5e1", "sha256": "1ea1c49631a45006b7ccdc38b64f4bd9d9f22f2323f5150388b27e16274c82bd" }, "downloads": -1, "filename": "django-geventpool-1.1.2.tar.gz", "has_sig": false, "md5_digest": "c85d2dbe9537820c8ecf2fb7e185c5e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12339, "upload_time": "2016-03-23T13:07:40", "url": "https://files.pythonhosted.org/packages/69/1c/18cb978435b73aab5e82f2aca24970b99ef77d8a95d80009783a6a361344/django-geventpool-1.1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "30fe83ad7ac6f3b8012f25cc5edd88cd", "sha256": "b71b62d0e78168ec193f311b452706f33792efa27d6516e899f229db6d344aa2" }, "downloads": -1, "filename": "django-geventpool-1.2.1.tar.gz", "has_sig": false, "md5_digest": "30fe83ad7ac6f3b8012f25cc5edd88cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12478, "upload_time": "2016-03-23T15:49:58", "url": "https://files.pythonhosted.org/packages/cf/f0/5062363b31a0d8fa518aaea025d887e68a276cad81f2bf85b65be6d06161/django-geventpool-1.2.1.tar.gz" } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "8cc147d6ae8424505353eee3c9562c45", "sha256": "5a4df1748ca9d474c6558a9230e2d9623e1d5e0302b3b4ea0eb59faa39ac69fe" }, "downloads": -1, "filename": "django-geventpool-1.2.2.tar.gz", "has_sig": false, "md5_digest": "8cc147d6ae8424505353eee3c9562c45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12526, "upload_time": "2016-03-24T14:14:47", "url": "https://files.pythonhosted.org/packages/5b/40/a3429a85f99ece04b09e6fcf1e5000df4ab895d559c994fbd0ceaf8dfc82/django-geventpool-1.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8cc147d6ae8424505353eee3c9562c45", "sha256": "5a4df1748ca9d474c6558a9230e2d9623e1d5e0302b3b4ea0eb59faa39ac69fe" }, "downloads": -1, "filename": "django-geventpool-1.2.2.tar.gz", "has_sig": false, "md5_digest": "8cc147d6ae8424505353eee3c9562c45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12526, "upload_time": "2016-03-24T14:14:47", "url": "https://files.pythonhosted.org/packages/5b/40/a3429a85f99ece04b09e6fcf1e5000df4ab895d559c994fbd0ceaf8dfc82/django-geventpool-1.2.2.tar.gz" } ] }