{ "info": { "author": "Spencer Mitchell", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "##########\nCuttlePool\n##########\n\nCuttlePool is a general purpose resource pooling implementation for use with\nlong lived resources and/or resources that are expensive to instantiate. It's\nkey features are:\n\nPool overflow\n Creates additional resources if the pool capacity has been reached and\n will remove the overflow when demand for resources decreases.\n\nResource harvesting\n Any resources that haven't been returned to the pool and are no longer\n referenced by anything outside the pool are returned to the pool. This helps\n prevent pool depletion when resources aren't explicitly returned to the\n pool and the resource wrapper is garbage collected.\n\nResource queuing\n If all else fails and no resource can be immediately found or made, the\n pool will wait a specified amount of time for a resource to be returned\n to the pool before raising an exception.\n\nHow-to Guide\n============\n\nUsing CuttlePool requires subclassing a ``CuttlePool`` object with a user\ndefined method ``normalize_resource()`` and ``ping()``. The example below uses\n``sqlite3`` connections as a resource, but CuttlePool is not limited to\nconnection drivers. ::\n\n >>> import sqlite3\n >>> from cuttlepool import CuttlePool\n >>> class SQLitePool(CuttlePool):\n ... def normalize_resource(self, resource):\n ... resource.row_factory = None\n ... def ping(self, resource):\n ... try:\n ... rv = resource.execute('SELECT 1').fetchall()\n ... return (1,) in rv\n ... except sqlite3.Error:\n ... return False\n >>> pool = SQLitePool(factory=sqlite3.connect, database='ricks_lab')\n\nLet's break this down line by line.\n\nFirst, the ``sqlite3`` module is imported. ``sqlite3.connect`` will be the\nunderlying resource factory.\n\n``CuttlePool`` is imported and subclassed. The ``normalize_resource()``\nmethod takes a resource, in this case a ``sqlite3.Connection`` instance created\nby ``sqlite3.connect``, as a parameter and changes it's properties. This is\nimportant because a resource can be modified while it's outside of the pool and\nany modifications made during that time will persist; this can have unintended\nconsequences when the resource is later retrieved from the pool.\n\nNext the ``ping()`` method is implemented, which also takes a resource, the\nsame as ``normalize_resource()``, as a parameter. ``ping()`` ensures the\nresource is functional; in this case, it checks that the ``sqlite3.Connection``\ninstance is open. If the resource is functional, ``ping()`` returns ``True``\nelse it returns ``False``. In the above example, a simple statement is executed\nand if the expected result is returned, it means the resource is open and\n``True`` is returned. The implementation of this method is really dependent on\nthe resource created by the pool and may not even be necessary.\n\nFinally an instance of ``SQLitePool`` is made. The ``sqlite3.connect`` method is\npassed to the instance along with the database name.\n\nThe ``CuttlePool`` object and as a result the ``SQLitePool`` object accepts any\nparameters that the underlying resource factory accepts as keyword arguments.\nThere are three other parameters the pool object accepts that are unrelated to\nthe resource factory. ``capacity`` sets the max number of resources the pool\nwill hold at any given time. ``overflow`` sets the max number of additional\nresources the pool will create when depleted. All overflow resources will be\nremoved from the pool if the pool is at capacity. ``timeout`` sets the amount\nof time in seconds the pool will wait for a resource to become free if the pool\nis depleted when a request for a resource is made.\n\nA resource from the pool can be treated the same way as an instance created by\nthe resource factory passed to the pool. In our example a resource can be used\njust like a ``sqlite3.Connection`` instance. ::\n\n >>> con = pool.get_resource()\n >>> cur = con.cursor()\n >>> cur.execute('INSERT INTO garage (invention_name, state) '\n ... 'VALUES (%s, %s)', ('Space Cruiser', 'damaged'))\n >>> con.commit()\n >>> cur.close()\n >>> con.close()\n\nCalling ``close()`` on the resource returns it to the pool instead of closing\nit. It is not necessary to call ``close()`` though. The pool tracks resources\nusing :class:`weakref.ref`, so any unreferenced resources will be collected and\nreturned to the pool. It is still a good idea to call ``close()`` though, since\nexplicit is better than implicit.\n\n.. note::\n Once ``close()`` is called on the resource object, it renders the\n object useless. The resource object received from the pool is a wrapper\n around the actual resource object and calling ``close()`` on it returns\n the resource to the pool and removes it from the wrapper effectively\n leaving it an empty shell to be garbage collected.\n\nFAQ\n===\n\nHow do I install it?\n--------------------\n\n``pip install cuttlepool``\n\nContributing\n------------\n\nIt's highly recommended to develop in a virtualenv.\n\nFork the repository.\n\nClone the repository::\n\n git clone https://github.com//cuttlepool.git\n\nInstall the package in editable mode::\n\n cd cuttlepool\n pip install -e .[dev]\n\nNow you're set. See the next section for running tests.\n\nRunning the tests\n-----------------\n\nTests can be run with the command ``pytest``.\n\nWhere can I get help?\n---------------------\n\nIf you haven't read the How-to guide above, please do that first. Otherwise,\ncheck the `issue tracker `_.\nYour issue may be addressed there and if it isn't please file an issue :)\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/smitchell556/cuttlepool", "keywords": "sql connection pool", "license": "BSD 3-Clause", "maintainer": "", "maintainer_email": "", "name": "cuttlepool", "package_url": "https://pypi.org/project/cuttlepool/", "platform": "", "project_url": "https://pypi.org/project/cuttlepool/", "project_urls": { "Homepage": "https://github.com/smitchell556/cuttlepool" }, "release_url": "https://pypi.org/project/cuttlepool/0.8.0/", "requires_dist": [ "pytest; extra == 'dev'" ], "requires_python": "", "summary": "A SQL pool implementation", "version": "0.8.0" }, "last_serial": 3626916, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "31bb8b9c2a2ae580fafb059fca8f712e", "sha256": "7e2ea3217c4618896ae2b1137b3e7712473c0ae710a429ec72e419295c502ea9" }, "downloads": -1, "filename": "cuttlepool-0.1.0-py2-none-any.whl", "has_sig": false, "md5_digest": "31bb8b9c2a2ae580fafb059fca8f712e", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 7603, "upload_time": "2017-04-06T22:54:15", "url": "https://files.pythonhosted.org/packages/1b/bf/9f740c4561e3784009ad30aa867c13e924c78c962d3431b49638ec1677ce/cuttlepool-0.1.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "49830e804c24d77cc2ffae7694b5e48d", "sha256": "f2f7c154747f3e7b4a3a0fb3ded45e8d489e6e1f2a3a0bfc02e4a87d606fbf1c" }, "downloads": -1, "filename": "cuttlepool-0.1.0.tar.gz", "has_sig": false, "md5_digest": "49830e804c24d77cc2ffae7694b5e48d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7260, "upload_time": "2017-04-06T22:54:17", "url": "https://files.pythonhosted.org/packages/96/f1/f6caf58d4fb7137393a4683c5572a009392001918525b68237c2a0f54e53/cuttlepool-0.1.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "e7e5870d4797fc3196c8001fd864603f", "sha256": "110a6fa178fd2370abc6033b8483f8c32f65a66c5dc1bf100c3e9cfed76a1b52" }, "downloads": -1, "filename": "cuttlepool-0.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "e7e5870d4797fc3196c8001fd864603f", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 7950, "upload_time": "2017-04-18T21:05:34", "url": "https://files.pythonhosted.org/packages/fe/9f/d5c9519c1a93dbb3f6eaa643d11a0431e6d5ea328dd7ae933558d59690d5/cuttlepool-0.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "79713a698547a12c42fab1050a3e2185", "sha256": "2e6cdc4bea9d3b12f3ae9f18723b96d1ea041d5427556740df999fdf2f5f98c0" }, "downloads": -1, "filename": "cuttlepool-0.2.1.tar.gz", "has_sig": false, "md5_digest": "79713a698547a12c42fab1050a3e2185", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7585, "upload_time": "2017-04-18T21:05:35", "url": "https://files.pythonhosted.org/packages/11/f0/78e549e55e5d336374239bf2e2fb5dadc1828ab46433f2957822af3777c9/cuttlepool-0.2.1.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "c89d8fc2b3afb679abc086a568e43712", "sha256": "62496aac0342a1715d4a6dd76a5ec94f20d380ee07f26cacbaae0552e3e45278" }, "downloads": -1, "filename": "cuttlepool-0.4.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c89d8fc2b3afb679abc086a568e43712", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9470, "upload_time": "2017-05-15T22:26:55", "url": "https://files.pythonhosted.org/packages/a3/c2/41db7fd3413fad9c77cad46a26bc5ce884c5d6a6092c8f6364f45cd402d3/cuttlepool-0.4.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b0093d15078dcbcc1f481e4603b6747", "sha256": "6f10762e3d50632e35b2d90fe00270889e4b315d698d3a9292afa315dba8fc1f" }, "downloads": -1, "filename": "cuttlepool-0.4.1.tar.gz", "has_sig": false, "md5_digest": "9b0093d15078dcbcc1f481e4603b6747", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9651, "upload_time": "2017-05-15T22:26:57", "url": "https://files.pythonhosted.org/packages/b9/63/71d338ad5343549ae7870cec320e83284ff47db688e9c2f6d1decad20be1/cuttlepool-0.4.1.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "9a06c4b542d0bf200171ec4b3aec5245", "sha256": "0f4dee8f5ee9c383cf8d59a69183547e170bedc4bbb336d342d961e26062647c" }, "downloads": -1, "filename": "cuttlepool-0.5.1-py3-none-any.whl", "has_sig": false, "md5_digest": "9a06c4b542d0bf200171ec4b3aec5245", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10107, "upload_time": "2018-01-04T22:29:43", "url": "https://files.pythonhosted.org/packages/60/b0/8b2fa3f99954ff7a68a69b2b23358458c29c212ca7837e6bcd087fd9edc9/cuttlepool-0.5.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "299a5bd54f77fc415e0a3a8f21015636", "sha256": "5b196f7b6100dfa2f927b2ea2c7987371d3089c637504d92c1507d72dc153f78" }, "downloads": -1, "filename": "cuttlepool-0.5.1.tar.gz", "has_sig": false, "md5_digest": "299a5bd54f77fc415e0a3a8f21015636", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10132, "upload_time": "2018-01-04T22:29:44", "url": "https://files.pythonhosted.org/packages/a0/db/8cf6403945e65bc282ca09af6e4defbcb7eee84e899a6f1ecc5fd29e8fd9/cuttlepool-0.5.1.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "2adeb494a1381b117d3384984a00c470", "sha256": "48c32df3f874915119f5072e491fdeeeddd6aa80d8fd6c670f47aae0a1a743ef" }, "downloads": -1, "filename": "cuttlepool-0.6.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2adeb494a1381b117d3384984a00c470", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9663, "upload_time": "2018-01-28T23:30:55", "url": "https://files.pythonhosted.org/packages/e2/c5/2de1b7c3ad6ab913a752a81f0ec3a16e42404d91e68f7c15a5cbb070842a/cuttlepool-0.6.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "523863652220d5d722da42287f20c962", "sha256": "826bab73ddaff0f5763ed03af646d0add81bb048c9ed27b44caaa9e9498a17e4" }, "downloads": -1, "filename": "cuttlepool-0.6.0.tar.gz", "has_sig": false, "md5_digest": "523863652220d5d722da42287f20c962", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10071, "upload_time": "2018-01-28T23:30:56", "url": "https://files.pythonhosted.org/packages/70/b7/a15ece0359188ff9e4f0ef4b18d29027d981f2caef19c78c5345ef257d04/cuttlepool-0.6.0.tar.gz" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "b47e9444d2a9e711ab2cb528f465193e", "sha256": "4d7f1dae80710c72574242e3db7a85e37653014d47b4b0d562873de4b5c540f6" }, "downloads": -1, "filename": "cuttlepool-0.7.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b47e9444d2a9e711ab2cb528f465193e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9596, "upload_time": "2018-02-09T18:16:47", "url": "https://files.pythonhosted.org/packages/d9/e5/f5dfcb2f1821d2928b5adc83597babd7b8033cf433344aaaf2a1e000a695/cuttlepool-0.7.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8b01c16fae37d3143a0ac352a2edd2c0", "sha256": "dd0c0e021f5528a1435464e181d9d4c166f2768df85b8e752ab8ce468c22dcb3" }, "downloads": -1, "filename": "cuttlepool-0.7.0.tar.gz", "has_sig": false, "md5_digest": "8b01c16fae37d3143a0ac352a2edd2c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10437, "upload_time": "2018-02-09T18:16:48", "url": "https://files.pythonhosted.org/packages/77/80/373f795e65596721bcf164d7e9513c1769f57b2d94674d0758fef5307c2a/cuttlepool-0.7.0.tar.gz" } ], "0.8.0": [ { "comment_text": "", "digests": { "md5": "e703245e27bf558fc2693649b2942c29", "sha256": "e00bbe2d1cf80506268dffb89ce6f180c850b3bacbf590a5ad8920fbb4f5b687" }, "downloads": -1, "filename": "cuttlepool-0.8.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e703245e27bf558fc2693649b2942c29", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10426, "upload_time": "2018-02-28T23:23:47", "url": "https://files.pythonhosted.org/packages/9c/21/d0b998f3c36ecd09c573755defd8c0cd2f71daeb414d3ec653123c5f70d7/cuttlepool-0.8.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1e8cc65f3c564d27eb9fec239987b0a8", "sha256": "670207f3e47e9d44047207caddc5c7b52efb1444dacaa3651a55972b22c54ef5" }, "downloads": -1, "filename": "cuttlepool-0.8.0.tar.gz", "has_sig": false, "md5_digest": "1e8cc65f3c564d27eb9fec239987b0a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12705, "upload_time": "2018-02-28T23:23:49", "url": "https://files.pythonhosted.org/packages/ab/88/a4e7190d383e12c85b25f2c6a012d58a3f013368e96cad174bee1fe233b9/cuttlepool-0.8.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e703245e27bf558fc2693649b2942c29", "sha256": "e00bbe2d1cf80506268dffb89ce6f180c850b3bacbf590a5ad8920fbb4f5b687" }, "downloads": -1, "filename": "cuttlepool-0.8.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e703245e27bf558fc2693649b2942c29", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10426, "upload_time": "2018-02-28T23:23:47", "url": "https://files.pythonhosted.org/packages/9c/21/d0b998f3c36ecd09c573755defd8c0cd2f71daeb414d3ec653123c5f70d7/cuttlepool-0.8.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1e8cc65f3c564d27eb9fec239987b0a8", "sha256": "670207f3e47e9d44047207caddc5c7b52efb1444dacaa3651a55972b22c54ef5" }, "downloads": -1, "filename": "cuttlepool-0.8.0.tar.gz", "has_sig": false, "md5_digest": "1e8cc65f3c564d27eb9fec239987b0a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12705, "upload_time": "2018-02-28T23:23:49", "url": "https://files.pythonhosted.org/packages/ab/88/a4e7190d383e12c85b25f2c6a012d58a3f013368e96cad174bee1fe233b9/cuttlepool-0.8.0.tar.gz" } ] }