{ "info": { "author": "Victor Lin, Andrey Smirnov", "author_email": "bornstub@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Twisted bindings for 0MQ\n========================\n\n.. contents::\n\nIntroduction\n------------\n\n.. note::\n\n This is not the `original version of txZMQ`_, this is a refactoried version\n of txZMQ by Victor Lin.\n \n .. _`original version of txZMQ`: http://pypi.python.org/pypi/txZMQ\n\ntxZMQ allows to integrate easily `0MQ `_ sockets into\nTwisted event loop (reactor).\n\ntxZMQ supports both CPython and PyPy.\n\nImprovement\n-----------\n\nOriginal API design of txZMQ was wrongly designed, and they are not reusable or\nhard to use, for example, to set HWM of a ZeroMQ socket, you need to change \nthe class level variable.::\n\n from txzmq import ZmqConnection\n ZmqConnection.highWaterMark = 100\n conn = ZmqConnection(factory)\n \nAs you can see the highWaterMark variable affects all connection made afterward.\nThis is obviously not a good design. \n\nAlso, the encapsulation of endpoints is not necessary. Sometimes you may need\nto connect or bind a address after a ZmqConnection was created, original \ndesign has no obvious way to do it. You need to pass endpoints when create a\nnew ZmqConnection.\n\nPUSH/PULL and PAIR connections are not present in original version. I add\nthose connection types in this library.\n\nThere is also `a serious bug`_ in original version. When read signal\nof FD is triggered before reactor perform another select, then txZMQ stop\nreading from that socket anymore. This version fixes the bug. \n\n.. _`a serious bug`: https://github.com/smira/txZMQ/pull/3\n\nRequirements\n------------\n\nNon-Python library required:\n\n* 0MQ library >= 2.1 (heavily tested with 2.1.4)\n\nPython packages required:\n\n* pyzmq (for CPython)\n* pyzmq-ctypes (for PyPy)\n* Twisted\n\n\nDetails\n-------\n\ntxZMQ introduces support for general 0MQ sockets by class ``ZmqConnection``\nthat can do basic event loop integration, sending-receiving messages in\nnon-blocking manner, scatter-gather for multipart messages.\n\ntxZMQ uses \u00d8MQ APIs to get file descriptor that is used to signal pending\nactions from \u00d8MQ library IO thread running in separate thread. This is used in\na custom file descriptor reader, which is then added to the Twisted reactor.\n\nFrom this class, one may implement the various patterns defined by 0MQ. For\nexample, special descendants of the ``ZmqConnection`` class,\n``ZmqPubConnection`` and ``ZmqSubConnection``, add special nice features for\nPUB/SUB sockets.\n\nRequest/reply pattern is achieved via XREQ/XREP sockets and classes ``ZmqXREQConnection``, \n``ZmqXREPConection``.\n\nPush/pull pattern is achieved via classes ``ZmqPushConnection``, \n``ZmqPullConection``.\n\nFinally, Pair pattern is achieved via classes ``ZmqPairConnection``.\n\nExample\n-------\n\nHere is an example of using txZMQ::\n\n import os\n import sys\n import time\n from optparse import OptionParser\n \n from twisted.internet import reactor\n \n import zmq\n from txzmq import ZmqFactory, ZmqPubConnection, ZmqSubConnection\n \n parser = OptionParser(\"\")\n parser.add_option(\"-m\", \"--method\", dest=\"method\", help=\"0MQ socket connection: bind|connect\")\n parser.add_option(\"-e\", \"--endpoint\", dest=\"endpoint\", help=\"0MQ Endpoint\")\n parser.add_option(\"-M\", \"--mode\", dest=\"mode\", help=\"Mode: publisher|subscriber\")\n parser.set_defaults(method=\"connect\", endpoint=\"epgm://eth1;239.0.5.3:10011\")\n \n (options, args) = parser.parse_args()\n \n zf = ZmqFactory()\n \n def bind_or_connect(s):\n if options.method == 'bind':\n s.bind(options.endpoint)\n elif options.method == 'connect':\n s.connect(options.endpoint)\n \n if options.mode == \"publisher\":\n pub = ZmqPubConnection(zf)\n bind_or_connect(pub)\n \n def publish():\n data = str(time.time())\n print \"publishing %r\" % data\n pub.send(data)\n \n reactor.callLater(1, publish)\n \n publish()\n else:\n def doPrint(msgs):\n print \"message received: %r\" % (msgs, )\n sub = ZmqSubConnection(zf, callback=doPrint)\n sub.setsockopt(zmq.SUBSCRIBE, '')\n bind_or_connect(sub)\n \n reactor.run()\n\n\nThe same example is available in the source code. You can run it from the\ncheckout directory with the following commands (in two different terminals)::\n\n examples/pub_sub.py --method=bind --endpoint=ipc:///tmp/sock --mode=publisher\n\n examples/pub_sub.py --method=connect --endpoint=ipc:///tmp/sock --mode=subscriber\n\nHacking\n-------\n\nSource code for txZMQ is available at `github `_;\nforks and pull requests are welcome.\n\nTo start hacking, fork at github and clone to your working directory. To use\nthe Makefile (for running unit tests, checking for PEP8 compliance and running\npyflakes), you will want to have ``virtualenv`` installed (it includes a\n``pip`` installation).\n\nCreate a branch, add some unit tests, write your code, check it and test it!\nSome useful make targets are:\n\n* ``make env``\n* ``make check``\n* ``make test``\n\nIf you don't have an environment set up, a new one will be created for you in\n``./env``. Additionally, txZMQ will be installed as well as required\ndevelopment libs.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/vic-txZMQ", "keywords": null, "license": "GPLv2", "maintainer": null, "maintainer_email": null, "name": "vic-txZMQ", "package_url": "https://pypi.org/project/vic-txZMQ/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/vic-txZMQ/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/vic-txZMQ" }, "release_url": "https://pypi.org/project/vic-txZMQ/0.5.2/", "requires_dist": null, "requires_python": null, "summary": "Twisted bindings for ZeroMQ", "version": "0.5.2" }, "last_serial": 801381, "releases": { "0.5.0": [ { "comment_text": "", "digests": { "md5": "42a7301b0b089b75da40c04e4a045ced", "sha256": "a58519d01254672132883ad662a7e3eb60829f863c0c9e18a68211ff0c778dfa" }, "downloads": -1, "filename": "vic-txZMQ-0.5.0.zip", "has_sig": false, "md5_digest": "42a7301b0b089b75da40c04e4a045ced", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26842, "upload_time": "2012-01-24T14:13:27", "url": "https://files.pythonhosted.org/packages/53/bd/3044c43a21af8f844ccc576b6f7deb926452dc70b653da3b68d4941e7156/vic-txZMQ-0.5.0.zip" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "5652a8dfcce7c20c8eb5d0bbf4b461cc", "sha256": "42acd7106c95ed1f29586b22d18855c491f2908d7d848ed22f339d755f4e0228" }, "downloads": -1, "filename": "vic-txZMQ-0.5.1.zip", "has_sig": false, "md5_digest": "5652a8dfcce7c20c8eb5d0bbf4b461cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27304, "upload_time": "2012-01-24T16:18:30", "url": "https://files.pythonhosted.org/packages/89/a4/8a5a9deca8eaa4cd811ff03ff299a2c6c8f46624aa21de98f10286e789ae/vic-txZMQ-0.5.1.zip" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "69b1d604c630d0dcd2866381ac688077", "sha256": "8b83ec6634b8c2a0acb65476d4b6a3ce8cb15c4d51774b14d4c69663b6562501" }, "downloads": -1, "filename": "vic-txZMQ-0.5.2.zip", "has_sig": false, "md5_digest": "69b1d604c630d0dcd2866381ac688077", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27760, "upload_time": "2012-02-25T18:54:23", "url": "https://files.pythonhosted.org/packages/ec/d1/6c083d9a1c26576d4f478d4068e344cde91aedc54a68a997c7a00ebfa75d/vic-txZMQ-0.5.2.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "69b1d604c630d0dcd2866381ac688077", "sha256": "8b83ec6634b8c2a0acb65476d4b6a3ce8cb15c4d51774b14d4c69663b6562501" }, "downloads": -1, "filename": "vic-txZMQ-0.5.2.zip", "has_sig": false, "md5_digest": "69b1d604c630d0dcd2866381ac688077", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27760, "upload_time": "2012-02-25T18:54:23", "url": "https://files.pythonhosted.org/packages/ec/d1/6c083d9a1c26576d4f478d4068e344cde91aedc54a68a997c7a00ebfa75d/vic-txZMQ-0.5.2.zip" } ] }