{ "info": { "author": "Quantlane", "author_email": "code@quantlane.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3 :: Only" ], "description": "aiopubsub - asyncio publish-subscribe within a process\n======================================================\n\nSimple pubsub pattern for asyncio applications.\n\naiopubsub is only tested with Python 3.6. There are no plans to support older versions.\n\n\n.. code-block:: python\n\n\timport asyncio\n\timport aiopubsub\n\timport logwood\n\n\tasync def main():\n\t\tlogwood.basic_config()\n\t\thub = aiopubsub.Hub()\n\t\tpublisher = aiopubsub.Publisher(hub, prefix = aiopubsub.Key('a'))\n\t\tsubscriber = aiopubsub.Subscriber(hub, 'subscriber_id')\n\n\t\tsub_key = aiopubsub.Key('a', 'b', '*')\n\t\tsubscriber.subscribe(sub_key)\n\n\t\tpub_key = aiopubsub.Key('b', 'c')\n\t\tpublisher.publish(pub_key, 'Hello subscriber')\n\t\tawait asyncio.sleep(0.001) # Let the callback fire.\n\t\t# \"('a', 'b', 'c') Hello subscriber\" will be printed.\n\n\t\tkey, message = await subscriber.consume()\n\t\tassert key == aiopubsub.Key('a', 'b', 'c')\n\t\tassert message == 'Hello subscriber'\n\n\t\tsubscriber.remove_all_listeners()\n\n\n\tasyncio.get_event_loop().run_until_complete(main())\n\nor, instead of directly subscribing to the key, we can create a listener that will call a synchronous callback\nwhen a new message arrives.\n\n.. code-block:: python\n\n\tdef print_message(key, message):\n\t\tprint(key, message)\n\n\tsubscriber.add_sync_listener(sub_key, print_message)\n\nOr, if we have a coroutine callback we can create an asynchronous listener:\n\n.. code-block:: python\n\n\tasync def print_message(key, message):\n\t\tawait asyncio.sleep(1)\n\t\tprint(key, message)\n\n\tsubscriber.add_async_listener(sub_key, print_message)\n\n\nAiopubsub will use `logwood `_ if it is installed, otherwise it will default\nto the standard logging module. Note that ``logwood`` is required to run tests.\n\n\nArchitecture\n------------\n\n**Hub** accepts messages from **Publishers** and routes them to **Subscribers**. Each message is routed by its\n**Key** - an iterable of strings forming a hierarchic namespace. Subscribers may subscribe to wildcard keys,\nwhere any part of the key may be replaced replaced with a ``*`` (star).\n\n``addedSubscriber`` and ``removedSubscriber`` messages\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWhen a new subscriber is added the Hub sends this message\n\n.. code-block::\n\n\t{\n\t\t\"key\": (\"key\", \"of\", \"added\", \"subscriber\"),\n\t\t\"currentSubscriberCount\": 2\n\t}\n\nunder the key ``('Hub', 'addedSubscriber', 'key', 'of', 'added', 'subscriber')`` (the part after ``addedSubscriber``\nis made of the subscribed key). Note the ``currentSubscriberCount`` field indicating how many subscribers are currently\nsubscribed.\n\nWhen a subscriber is removed a message in the same format is sent, but under the key\n``('Hub', 'removedSubscriber', 'key', 'of', 'added', 'subscriber')``.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/qntln/aiopubsub", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "aiopubsub", "package_url": "https://pypi.org/project/aiopubsub/", "platform": "", "project_url": "https://pypi.org/project/aiopubsub/", "project_urls": { "Homepage": "https://github.com/qntln/aiopubsub" }, "release_url": "https://pypi.org/project/aiopubsub/2.1.5/", "requires_dist": null, "requires_python": "", "summary": "Simple pubsub pattern for asyncio applications", "version": "2.1.5" }, "last_serial": 3840162, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "6c5ebc9fe09540af0da1de9cae67392d", "sha256": "7f2153b245d6d1a2e98a7a1ab443b83bf431c5df6a325562bd2dc6c33493325d" }, "downloads": -1, "filename": "aiopubsub-1.0.0.tar.gz", "has_sig": true, "md5_digest": "6c5ebc9fe09540af0da1de9cae67392d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5568, "upload_time": "2016-12-02T16:30:14", "url": "https://files.pythonhosted.org/packages/9f/3a/cb82118b8c10d1d48324a5a2ff653f38eb071e99314c7f2c451e3ae23523/aiopubsub-1.0.0.tar.gz" } ], "2.1.5": [ { "comment_text": "", "digests": { "md5": "245fe25ac3cffbf92a462e4316b55f2a", "sha256": "e75aae34d43506967dd92ce792995b8e815ddb31d42a114260036892d8693e91" }, "downloads": -1, "filename": "aiopubsub-2.1.5.tar.gz", "has_sig": true, "md5_digest": "245fe25ac3cffbf92a462e4316b55f2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7786, "upload_time": "2018-05-07T08:18:09", "url": "https://files.pythonhosted.org/packages/a2/90/fa234a5bf728346bd22f0c916b48008fa9dfd074c93f10e0dad7324f685d/aiopubsub-2.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "245fe25ac3cffbf92a462e4316b55f2a", "sha256": "e75aae34d43506967dd92ce792995b8e815ddb31d42a114260036892d8693e91" }, "downloads": -1, "filename": "aiopubsub-2.1.5.tar.gz", "has_sig": true, "md5_digest": "245fe25ac3cffbf92a462e4316b55f2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7786, "upload_time": "2018-05-07T08:18:09", "url": "https://files.pythonhosted.org/packages/a2/90/fa234a5bf728346bd22f0c916b48008fa9dfd074c93f10e0dad7324f685d/aiopubsub-2.1.5.tar.gz" } ] }