{ "info": { "author": "Cameron Simpson", "author_email": "cs@cskk.id.au", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "*Release 20190812*:\nMultiOpenMixin: no longer subclass cs.obj.O.\nMultiOpenMixin: remove `lock` param support, the mixin has its own lock.\nMultiOpen: drop `lock` param support, no longer used by MultiOpenMixin.\nMultiOpenMixin: do finalise inside the lock for the same reason as shutdown (competition with open/startup).\nMultiOpenMixin.close: new `unopened_ok=False` parameter intended for callback closes which might fire even if the initial open does not occur.\n\nResource management classes and functions.\n\n## Class `ClosedError`\n\nMRO: `builtins.Exception`, `builtins.BaseException` \nException for operations invalid when something is closed.\n\n## Class `MultiOpen`\n\nMRO: `MultiOpenMixin` \nContext manager class that manages a single open/close object\nusing a MultiOpenMixin.\n\n### Method `MultiOpen.__init__(self, openable, finalise_later=False)`\n\nInitialise: save the `openable` and call the MultiOpenMixin initialiser.\n\n## Class `MultiOpenMixin`\n\nA mixin to count open and close calls, and to call .startup\non the first .open and to call .shutdown on the last .close.\n\nRecommended subclass implementations do as little as possible\nduring __init__, and do almost all setup during startup so\nthat the class may perform multiple startup/shutdown iterations.\n\nIf used as a context manager calls open()/close() from\n__enter__() and __exit__().\n\nMultithread safe.\n\nThis mixin defines ._lock = RLock(); subclasses need not\nbother, but may supply their own lock.\n\nClasses using this mixin need to define .startup and .shutdown.\n\n### Method `MultiOpenMixin.__init__(self, finalise_later=False)`\n\nInitialise the MultiOpenMixin state.\n\nParameters:\n* `finalise_later`: do not notify the finalisation Condition on\n shutdown, require a separate call to .finalise().\n This is mode is useful for objects such as queues where\n the final close prevents further .put calls, but users\n calling .join may need to wait for all the queued items\n to be processed.\n\nTODO:\n* `subopens`: if true (default false) then .open will return\n a proxy object with its own .closed attribute set by the\n proxy's .close.\n\n## Function `not_closed(func)`\n\nDecorator to wrap methods of objects with a .closed property\nwhich should raise when self.closed.\n\n## Class `Pool`\n\nMRO: `cs.obj.O` \nA generic pool of objects on the premise that reuse is cheaper than recreation.\n\nAll the pool objects must be suitable for use, so the\n`new_object` callable will typically be a closure.\nFor example, here is the __init__ for a per-thread AWS Bucket using a\ndistinct Session:\n\n def __init__(self, bucket_name):\n Pool.__init__(self, lambda: boto3.session.Session().resource('s3').Bucket(bucket_name)\n\n### Method `Pool.__init__(self, new_object, max_size=None, lock=None)`\n\nInitialise the Pool with creator `new_object` and maximum size `max_size`.\n\nParameters:\n* `new_object` is a callable which returns a new object for the Pool.\n* `max_size`: The maximum size of the pool of available objects saved for reuse.\n If omitted or `None`, defaults to 4.\n If 0, no upper limit is applied.\n* `lock`: optional shared Lock; if omitted or `None` a new Lock is allocated\n\n## Class `RunState`\n\nA class to track a running task whose cancellation may be requested.\n\nIts purpose is twofold, to provide easily queriable state\naround tasks which can start and stop, and to provide control\nmethods to pronounce that a task has started (`.start`),\nshould stop (`.cancel`)\nand has stopped (`.stop`).\n\nA `RunState` can be used a a context manager, with the enter\nand exit methods calling `.start` and `.stop` respectively.\nNote that if the suite raises an exception\nthen the exit method also calls `.cancel` before the call to `.stop`.\n\nMonitor or daemon processes can poll the `RunState` to see when\nthey should terminate, and may also manage the overall state\neasily using a context manager.\nExample:\n\n def monitor(self):\n with self.runstate:\n while not self.runstate.cancelled:\n ... main loop body here ...\n\nA `RunState` has three main methods:\n* `.start()`: set `.running` and clear `.cancelled`\n* `.cancel()`: set `.cancelled`\n* `.stop()`: clear `.running`\n\nA `RunState` has the following properties:\n* `cancelled`: true if `.cancel` has been called.\n* `running`: true if the task is running.\n Further, assigning a true value to it also sets `.start_time` to now.\n Assigning a false value to it also sets `.stop_time` to now.\n* `start_time`: the time `.running` was last set to true.\n* `stop_time`: the time `.running` was last set to false.\n* `run_time`: `max(0,.stop_time-.start_time)`\n* `stopped`: true if the task is not running.\n* `stopping`: true if the task is running but has been cancelled.\n* `notify_start`: a set of callables called with the `RunState` instance\n to be called whenever `.running` becomes true.\n* `notify_end`: a set of callables called with the `RunState` instance\n to be called whenever `.running` becomes false.\n* `notify_cancel`: a set of callables called with the `RunState` instance\n to be called whenever `.cancel` is called.\n\n## Class `RunStateMixin`\n\nMixin to provide convenient access to a `RunState`.\n\nProvides: `.runstate`, `.cancelled`, `.running`, `.stopping`, `.stopped`.\n\n### Method `RunStateMixin.__init__(self, runstate=None)`\n\nInitialise the `RunStateMixin`; sets the `.runstate` attribute.\n\n`runstate`: `RunState` instance or name.\nIf a `str`, a new `RunState` with that name is allocated.\n\n\n\n# Release Log\n\n*Release 20190812*:\nMultiOpenMixin: no longer subclass cs.obj.O.\nMultiOpenMixin: remove `lock` param support, the mixin has its own lock.\nMultiOpen: drop `lock` param support, no longer used by MultiOpenMixin.\nMultiOpenMixin: do finalise inside the lock for the same reason as shutdown (competition with open/startup).\nMultiOpenMixin.close: new `unopened_ok=False` parameter intended for callback closes which might fire even if the initial open does not occur.\n\n*Release 20190617*:\nRunState.__exit__: if an exception was raised call .canel() before calling .stop().\n\n*Release 20190103*:\nBugfixes for context managers.\nMultiOpenMixin fixes and changes.\nRunState improvements.\n\n*Release 20171024*:\nbugfix MultiOpenMixin finalise logic and other small logic fixes and checs\nnew class RunState for tracking or controlling a running task\n\n*Release 20160828*:\nUse \"install_requires\" instead of \"requires\" in DISTINFO.\n\n*Release 20160827*:\nBREAKING CHANGE: rename NestingOpenCloseMixin to MultiOpenMixin.\nNew Pool class for generic object reuse.\nAssorted minor improvements.\n\n*Release 20150115*:\nFirst PyPI release.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/cameron_simpson/css/commits/all", "keywords": "python2,python3", "license": "GNU General Public License v3 or later (GPLv3+)", "maintainer": "", "maintainer_email": "", "name": "cs.resources", "package_url": "https://pypi.org/project/cs.resources/", "platform": "", "project_url": "https://pypi.org/project/cs.resources/", "project_urls": { "Homepage": "https://bitbucket.org/cameron_simpson/css/commits/all" }, "release_url": "https://pypi.org/project/cs.resources/20190812/", "requires_dist": null, "requires_python": "", "summary": "resourcing related classes and functions", "version": "20190812" }, "last_serial": 5663500, "releases": { "20150115": [ { "comment_text": "", "digests": { "md5": "bfcf94962ae530f73b574928b816f796", "sha256": "ebb3c6352067189068ddc0716fcadb5a6233fa17aa4a109794588dc008ebf099" }, "downloads": -1, "filename": "cs.resources-20150115.tar.gz", "has_sig": false, "md5_digest": "bfcf94962ae530f73b574928b816f796", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3191, "upload_time": "2015-01-18T06:12:01", "url": "https://files.pythonhosted.org/packages/66/a0/2ae45893df5a9de748c73689c449098ebc725b70d26f7bfc0078a0ec0480/cs.resources-20150115.tar.gz" } ], "20160827": [ { "comment_text": "", "digests": { "md5": "d6c6d061207e6063bd0d5b63355a5f20", "sha256": "4acd7a61ed000e30b980686379a0a1887f889d074697618a1811f45921bc5a24" }, "downloads": -1, "filename": "cs.resources-20160827.tar.gz", "has_sig": false, "md5_digest": "d6c6d061207e6063bd0d5b63355a5f20", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3720, "upload_time": "2016-08-27T03:29:14", "url": "https://files.pythonhosted.org/packages/a0/2c/8dcaf5a6b61167773d367a6dee184e2e61f3a55d32b58cbe7cd927b3c5c7/cs.resources-20160827.tar.gz" } ], "20160828": [ { "comment_text": "", "digests": { "md5": "ee121e8ff8f5597c6f401450a39fff7b", "sha256": "d7bdfd01d9aafef601a67f255c938ec694e2ef1496c1f10ed7359a40647cb4cd" }, "downloads": -1, "filename": "cs.resources-20160828.tar.gz", "has_sig": false, "md5_digest": "ee121e8ff8f5597c6f401450a39fff7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4074, "upload_time": "2016-08-28T06:10:34", "url": "https://files.pythonhosted.org/packages/be/cb/62e1c2073133f95ecf9faf80c06b46a611a555e822327d5b259a7ad757d0/cs.resources-20160828.tar.gz" } ], "20171024": [ { "comment_text": "", "digests": { "md5": "6d42ec52d773f4c7cc0aafe780f84589", "sha256": "9bac286612d420b4f7e2b6da1dbde46e05d036b2fa2592d6803d02274e6ba449" }, "downloads": -1, "filename": "cs.resources-20171024.tar.gz", "has_sig": false, "md5_digest": "6d42ec52d773f4c7cc0aafe780f84589", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4725, "upload_time": "2017-10-24T04:26:05", "url": "https://files.pythonhosted.org/packages/92/7b/5839d5fdb2193c86d4669426c640a67757898d1a12f1e5a40caa93eae83b/cs.resources-20171024.tar.gz" } ], "20190103": [ { "comment_text": "", "digests": { "md5": "1dcba0e66e6def7f18c07b56c4675d1e", "sha256": "e19579c821250053c8e82eb6af9480aef8c0d8b51a7d42d53da0cad124356f3f" }, "downloads": -1, "filename": "cs.resources-20190103.tar.gz", "has_sig": false, "md5_digest": "1dcba0e66e6def7f18c07b56c4675d1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7272, "upload_time": "2019-01-02T22:52:10", "url": "https://files.pythonhosted.org/packages/48/a9/d1ba76df9f394ef428350179484ce0babd6f9cca2830f9a4b671c1f76f87/cs.resources-20190103.tar.gz" } ], "20190617": [ { "comment_text": "", "digests": { "md5": "d04a20c21e0198319b5ed3923088d222", "sha256": "755c520a79b305b002762b0eb2b339b55f4279cd412a6cceacb768330d4ff03e" }, "downloads": -1, "filename": "cs.resources-20190617.tar.gz", "has_sig": false, "md5_digest": "d04a20c21e0198319b5ed3923088d222", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8612, "upload_time": "2019-06-17T02:52:46", "url": "https://files.pythonhosted.org/packages/18/12/f2ac148c0c53daa8969159909dd5be6762a16ff2084f61af3be325f6919a/cs.resources-20190617.tar.gz" } ], "20190812": [ { "comment_text": "", "digests": { "md5": "c47c7336cdb86f535d30574cb3483133", "sha256": "632c48dd605a854cf7849e801e0eed8c4868cd2a25bc3bf1324b0be1685686fd" }, "downloads": -1, "filename": "cs.resources-20190812.tar.gz", "has_sig": false, "md5_digest": "c47c7336cdb86f535d30574cb3483133", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9388, "upload_time": "2019-08-11T23:42:13", "url": "https://files.pythonhosted.org/packages/99/54/af575f280c44b9676cecf03ad827392609949f0455e4799934da9277ecb1/cs.resources-20190812.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c47c7336cdb86f535d30574cb3483133", "sha256": "632c48dd605a854cf7849e801e0eed8c4868cd2a25bc3bf1324b0be1685686fd" }, "downloads": -1, "filename": "cs.resources-20190812.tar.gz", "has_sig": false, "md5_digest": "c47c7336cdb86f535d30574cb3483133", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9388, "upload_time": "2019-08-11T23:42:13", "url": "https://files.pythonhosted.org/packages/99/54/af575f280c44b9676cecf03ad827392609949f0455e4799934da9277ecb1/cs.resources-20190812.tar.gz" } ] }