{ "info": { "author": "Rob Blackbourn", "author_email": "rob.blackbourn@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7" ], "description": "# countdown-event\n\nA synchronization class which blocks when the count is not zero.\n\nHere's an example\n\n```python\nimport asyncio\nfrom countdown_event import CountdownEvent\n\nasync def long_running_task(countdown_event,cancellation_event):\n count = countdown_event.increment()\n print(f'incremented count to {count}')\n try:\n print('Waiting for cancellation event')\n await cancellation_event.wait()\n finally:\n count = countdown_event.decrement()\n print(f'decremented count to {count}')\n\nasync def stop_tasks(secs, countdown_event, cancellation_event):\n print(f'waiting {secs} seconds before setting the cancellation event')\n await asyncio.sleep(secs)\n print('setting the cancellation event')\n cancellation_event.set()\n print('waiting for tasks to finish')\n await countdown_event.wait()\n print('countdown event cleared')\n\nasync def main_async():\n cancellation_event = asyncio.Event()\n countdown_event = CountdownEvent()\n tasks = [\n long_running_task(countdown_event, cancellation_event),\n long_running_task(countdown_event, cancellation_event),\n long_running_task(countdown_event, cancellation_event),\n stop_tasks(5, countdown_event, cancellation_event)\n ]\n await asyncio.wait(tasks)\n assert countdown_event.count == 0\n print(\"done\")\n\nif __name__ == \"__main__\":\n asyncio.run(main_async())\n```\n\nHere's the output.\n\n```\nincremented count to 1\nWaiting for cancellation event\nincremented count to 2\nWaiting for cancellation event\nwaiting 5 seconds before setting the cancellation event\nincremented count to 3\nWaiting for cancellation event\nsetting the cancellation event\nwaiting for tasks to finish\ndecremented count to 2\ndecremented count to 1\ndecremented count to 0\ncountdown event cleared\ndone\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rob-blackbourn/countdown-event", "keywords": "", "license": "Apache-2.0", "maintainer": "Rob Blackbourn", "maintainer_email": "rob.blackbourn@gmail.com", "name": "countdown-event", "package_url": "https://pypi.org/project/countdown-event/", "platform": "", "project_url": "https://pypi.org/project/countdown-event/", "project_urls": { "Homepage": "https://github.com/rob-blackbourn/countdown-event", "Repository": "https://github.com/rob-blackbourn/countdown-event" }, "release_url": "https://pypi.org/project/countdown-event/0.1.0/", "requires_dist": null, "requires_python": ">=3.7,<4.0", "summary": "An asyncio event which blocks until the count reaches zero", "version": "0.1.0" }, "last_serial": 5686988, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "ed7a548e57a57afaaa069ce477857538", "sha256": "07b811a6a68d2288783b1d22908639f577014bdd3b9c38d534507852b5c5aa78" }, "downloads": -1, "filename": "countdown_event-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ed7a548e57a57afaaa069ce477857538", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 6187, "upload_time": "2019-08-16T10:49:53", "url": "https://files.pythonhosted.org/packages/6f/c8/421d3bbb181e1c4c6a0f74f8bbc18810d1dcfe6654131331e3749e7e1950/countdown_event-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e154ceb499a17973929e59cfbea25738", "sha256": "9e7c316f3534d2f64f448808b3d4f6932d71f055364129bbf380e59d55bf3ec4" }, "downloads": -1, "filename": "countdown-event-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e154ceb499a17973929e59cfbea25738", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 6029, "upload_time": "2019-08-16T10:49:51", "url": "https://files.pythonhosted.org/packages/34/cf/e87d281df032dfb8c8385f459eddbb382e5e8a65ff8f8ef757ccab6e61b1/countdown-event-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ed7a548e57a57afaaa069ce477857538", "sha256": "07b811a6a68d2288783b1d22908639f577014bdd3b9c38d534507852b5c5aa78" }, "downloads": -1, "filename": "countdown_event-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ed7a548e57a57afaaa069ce477857538", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.7,<4.0", "size": 6187, "upload_time": "2019-08-16T10:49:53", "url": "https://files.pythonhosted.org/packages/6f/c8/421d3bbb181e1c4c6a0f74f8bbc18810d1dcfe6654131331e3749e7e1950/countdown_event-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e154ceb499a17973929e59cfbea25738", "sha256": "9e7c316f3534d2f64f448808b3d4f6932d71f055364129bbf380e59d55bf3ec4" }, "downloads": -1, "filename": "countdown-event-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e154ceb499a17973929e59cfbea25738", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.7,<4.0", "size": 6029, "upload_time": "2019-08-16T10:49:51", "url": "https://files.pythonhosted.org/packages/34/cf/e87d281df032dfb8c8385f459eddbb382e5e8a65ff8f8ef757ccab6e61b1/countdown-event-0.1.0.tar.gz" } ] }