{ "info": { "author": "sakost", "author_email": "sakost01+expiring_object@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "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", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Expiring_object \n![[PyPI](https://pypi.python.org/project/expiring_object)](https://img.shields.io/pypi/v/expiring_object.svg)\n![License](https://img.shields.io/pypi/l/expiring_object.svg)\n![Status](https://img.shields.io/pypi/status/expiring_object.svg)\n![Python versions](https://img.shields.io/pypi/pyversions/expiring_object.svg)\n![Downloads](https://img.shields.io/pypi/dw/expiring_object.svg)\nThis module provides a simple way to build self-removal objects\n\n## Examples\n```python\nimport time\n\nfrom expiring_object import object_factory, Dispatcher\n\nclass Stub:\n pass\n\nwith Dispatcher(expiring_time=10, maxlen=10) as dp:\n obj = object_factory(Stub(), dp) # pass object that you want to self-remove and a dispatcher instance\n # do something\n time.sleep(10)\n # the object was self-removed\n print(obj) # raises ReferenceError\n\n```\n\nAlso you can use this way:\n```python\nfrom weakref import proxy\n\ndp = Dispatcher(10)\ndp.start()\nsome_ref = Stub()\nweak_ref = proxy(some_ref) # a weak reference to an object\ndp.add(some_ref)\n# you must delete your link to this object\n# in another way only handler(if specified) will ba called\ndel some_ref \n# do something\ntime.sleep(10)\n# the object was self-removed\ndp.stop()\ndel weak_ref # this proxy object already not needs\n\n```\n\nAlso you can pass an object that has a callable attribute named `_handler`\n
It is calling (and then deleting item too) when the lifetime has expired:\n```python\nclass Stub:\n def _handler(self):\n print('deleting `stub`')\ndp.add(Stub())\n```\n> Note: You should remind that this object must not have another strong references\n### License\nThis project provided by a MIT license\n\nAlso all issues are welcome\n\n> Note that it is an alpha branch\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/sakost/expiring_object", "keywords": "expiring object self-removal", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "expiring_object", "package_url": "https://pypi.org/project/expiring_object/", "platform": "", "project_url": "https://pypi.org/project/expiring_object/", "project_urls": { "Homepage": "https://github.com/sakost/expiring_object" }, "release_url": "https://pypi.org/project/expiring_object/0.0.1a3/", "requires_dist": null, "requires_python": "", "summary": "Provides making self-removal objects", "version": "0.0.1a3" }, "last_serial": 3807467, "releases": { "0.0.1a2": [ { "comment_text": "", "digests": { "md5": "1dfe5de9b5d7870aa986bca026fe03b5", "sha256": "00fb13d902a2e90aac1157078282368da05a693a7e7542217c4d8b3d294b1d31" }, "downloads": -1, "filename": "expiring_object-0.0.1a2.tar.gz", "has_sig": false, "md5_digest": "1dfe5de9b5d7870aa986bca026fe03b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2751, "upload_time": "2018-04-25T16:24:15", "url": "https://files.pythonhosted.org/packages/65/c8/50b9dff0ebd7667a81cd9bba898f54cc5b014f67963f8c963b863f6bde3e/expiring_object-0.0.1a2.tar.gz" } ], "0.0.1a3": [ { "comment_text": "", "digests": { "md5": "a06439b4d62ebddbfb2e4508195f2bf5", "sha256": "89a841beb3a64398fd16c377266867d860cfd658dd6dac0287b474471f9e455b" }, "downloads": -1, "filename": "expiring_object-0.0.1a3.tar.gz", "has_sig": false, "md5_digest": "a06439b4d62ebddbfb2e4508195f2bf5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2776, "upload_time": "2018-04-25T16:28:24", "url": "https://files.pythonhosted.org/packages/f7/14/f36b797a40ffea02c23b755dac2af2116ba51ee1ae16e25318498314db47/expiring_object-0.0.1a3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a06439b4d62ebddbfb2e4508195f2bf5", "sha256": "89a841beb3a64398fd16c377266867d860cfd658dd6dac0287b474471f9e455b" }, "downloads": -1, "filename": "expiring_object-0.0.1a3.tar.gz", "has_sig": false, "md5_digest": "a06439b4d62ebddbfb2e4508195f2bf5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2776, "upload_time": "2018-04-25T16:28:24", "url": "https://files.pythonhosted.org/packages/f7/14/f36b797a40ffea02c23b755dac2af2116ba51ee1ae16e25318498314db47/expiring_object-0.0.1a3.tar.gz" } ] }