{ "info": { "author": "Guillaume Schworer", "author_email": "guillaume.schworer@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Documentation :: Sphinx" ], "description": ".. hein\n\n.. image:: http://img.shields.io/badge/license-GPLv3-blue.svg?style=flat\n\n :target: https://github.com/ceyzeriat/hein/blob/master/LICENSE\n\n:Name: hein\n:Website: https://github.com/ceyzeriat/hein\n:Author: Guillaume Schworer\n:Version: 0.2\n\nHein: Advanced Subscriber-Publisher Socket Communication. Fully compatible python2 and 3.\n\nThe native TPC/IP sockets implement a N-to-1 communication scheme: many clients (e.g. browsers) talk to a unique server (e.g. internet provider server) and engage a 1-to-1 communication (e.g. url request) with the server from which they will all get their own individual answers (e.g. web page). In this particular case, the server is passive: the only thing it does is answer the clients in a 1-to-1 communication.\nIf there is no client, the server does nothing. If there is no server, the client returns an error.\n\nNow let's imagine the reverse case where one wants to broadcast the same message to N listeners (each of them in a perfectly separate and independent environment/process/namespace), where N is subject to changing with time, and no matter if some of the listeners are launched, not launched (yet), or dropped.\n\nThis is a typical case where one needs a unique client to talk to several listening servers... and where the servers did themselves the \"connection step\" towards the broadcasting client... and where the client is broadcasting its messages even if no server is actually listening.\n\nWell, my friend, you are stuck.\n\nActually not, because this is exactly what `hein` does: 1-Publisher to N-Subscriber ashynchronous socket communication, turn-key - check the example below.\n\nNB: ``PyDispatcher``, ``Dispatch``, ``PyPubSub``, ``smokesignal`` or other similar libraries will get you to the point where several threads can talk to each other - that is great for some applications, but threads are not processes and you will be required to share the publisher object among subscribers: this is not an option when subscribers run in separate processes, possibly on different machines. ``ZeroMQ`` will get you to the point where you can talk between processes. However, all of the asynchronous heavy logistics is left for you to implement, and the socket connections will crash when a subscriber drops (unless you cover this case in your own implementation as well). Both of these tweaks are natively covered in ``hein``: minimal effort. Also, hein requires no deamon to be run.\n\n\nExample\n=======\n\nStraight to the point: launch 3 terminals in which you should start an interactive python interpreter (not an IDE).\n\nIn the first terminal (listener 1), type:\n\n.. code-block:: python\n\n from hein import SocReceiver\n r = SocReceiver(port=50007, name=\"Captain\")\n \nin the second one (transmitter), type:\n\n.. code-block:: python\n\n from hein import SocTransmitter\n t = SocTransmitter(port=50007, nreceivermax=2)\n \nYou will instantly see the transmitter terminal wishing a hearful welcome to its first listener.\n\nIn in the third one (listener 2), type:\n\n.. code-block:: python\n\n from hein import SocReceiver\n r = SocReceiver(port=50007, name=\"Kirk\")\n \nHere again, the transmitter terminal acknoledges the connection of the second listener. Now type in the transmitter terminal:\n\n.. code-block:: python\n\n t.tell_raw('hello!')\n \nAnd you will see the message appear in both listening terminals.\n\nNow close one listener and type:\n\n.. code-block:: python\n \n t.ping()\n\nOnly one listener is listed with the True (is connected) flag. Now let's try another one that keeps the type of the inputs:\n\n.. code-block:: python\n\n from datetime import datetime\n import pytz\n \n t.tell_json({'string': 'hello', 'integer': 34, 'float': 13.4, 'd': datetime(2017, 12, 3, tzinfo=pytz.UTC)})\n\nThe receiver will get exactly the same thing:\n\n.. code-block:: python\n\n {'integer': 34, 'float': 13.4, 'string': 'hello', 'd': datetime.datetime(2017, 12, 3, 0, 0, tzinfo=)}\n\n\nObviously, the behavior at connection and reception is driven by callback functions, which by default only print the listener's names or the message transmitted.\nAll you will need now is write your own functions to replace these default callbacks.\nThat's it.\n\nNote that, as you probably have seen when running the example/teaser, that the communication are natively non-blocking and asynchronous: no need to do the ennoying threading work yourself, `hein` library is turnkey solution (unlike ZeroMQ).\n\nThe best typical example of the use of hein is having several applications talking to each other: they are all busy doing their own things but still get messages from each other at the time their are sent (i.e. async, not at the time they are not busy anymore to process them).\n\nDocumentation\n=============\n\nRefer to this page for detailed API documentation, http://pythonhosted.org/hein/hein.html\n\n\nRequirements\n============\n\nHein requires the following Python packages:\n\n* socket: Really?\n* threading, select: for threading and port-reading\n* json: for unpacking the message\n* time, os, re: for basic stuff\n* byt: to handle chains of bytes identically no matter the python version\n* pytz: optional, for handling datetime-timezones\n\n\nInstallation\n============\n\nThe easiest and fastest way for you to get the package and run is to install hein through pip::\n\n $ pip install hein\n\nYou can also download Hein source from GitHub and type::\n\n $ python setup.py install\n\nDependency on byt will be installed automatically. Refer to the requirements section. If you have a standard install of python (or any fancier distribution like anaconda), you should be good to go.\n\nContributing\n============\n\nCode writing\n------------\n\nCode contributions are welcome! Just send a pull request on GitHub and we will discuss it. In the `issue tracker`_ you may find pending tasks.\n\nBug reporting\n-------------\n\nIf you think you've found one please refer to the `issue tracker`_ on GitHub.\n\n.. _`issue tracker`: https://github.com/ceyzeriat/hein/issues\n\nAdditional options\n------------------\n\nYou can either send me an e-mail or add it to the issues/wishes list on GitHub.\n\nCiting\n======\n\nIf you use Hein on your project, please\n`drop me a line `, you will get fixes and additional options earlier.\n\nLicense\n=======\n\nHein is released under the GNU General Public License v3 or later (GPLv3+). Please refer to the LICENSE file.\n\n\nChangelog\n---------\n\n0.2.3 (2018-04-27)\n+++++++++++++++++++\n\n- Renamed tell_json to tell\n- Fixed strict=False in json.loads to accept all bytes\n- Fixed support for python2, specifically json.loads rejecting bytes\n\n\n0.2.0 (2018-04-26)\n+++++++++++++++++++\n\n- Deprecated all \"tell_*\" methods of soctransmitter except tell_raw and tell_json\n- Both tell_raw and tell_json take an optional tag (str) to indicate what kind of message is transmitted\n- tell_json method automatically conserves the type of the value passed\n- tell_json method takes an optional unpack (bool, default True) argument that allows to not automatically unpack the message upon reception\n\n\n0.1.13 (2017-12-17)\n+++++++++++++++++++\n\n- Added tell_json and tell_json_ext which are able to pass any data structure, and keep the type information.\n- tell_json is a convenience method that uses a pure-json implementation of the serializer, which means that python3 will not be able to serialize bytes.\n- tell_json_ext is a custom serializer that is cross-consistent between python 2 and 3, and will deal properly with bytes as well as datetime objects.\n- fix README\n\n\n0.1.9 (2017-11-12)\n++++++++++++++++++\n\n- Added tell_list_type and tell_dict_type which keep the type of the data over transmission (works for int, float, bool, None, Byt, datetime.datetime, datetime.date, datetime.time, str, unicode (Pyt2), and bytes (Pyt3))\n- Modified 'tell' methods to accept unicode characters. Python3 built-in 'str' and Pyhton2 built-in 'unicode' are encoded as \"utf-8\", Python2 built-in 'str' and Python2/3 'bytes' are encoded as \"ascii\" (i.e. \"latin-1\").\n\n\n0.1.8 (2017-10-28)\n++++++++++++++++++\n\n- Added tell_list\n- Fixed infinite connection looping when adding two socreceivers with same name\n\n\n0.1.7 (2017-04-04)\n++++++++++++++++++\n\n- Implemented connect parameter in SocReceiver\n- Fixed bug on key being compared to instance Byt\n- Fixed bug with 'key' keyword in tell_key\n\n\n0.1.4 (2017-04-03)\n++++++++++++++++++\n\n- Added hostname to SocReceiver\n- Added tell_key method to SocTransmitter to send any key-type of dictionary\n\n\n0.1.2 (2017-03-22)\n++++++++++++++++++\n\n- Made timeout parameter of acknowledgement of receipt accessible\n\n\n0.1.1 (2017-03-09)\n++++++++++++++++++\n\n- Improved high-frequency management of communications\n- Changed maximum communication frequency to 100 Hz; faster communications are merged\n\n\n0.1.0 (2017-03-05)\n++++++++++++++++++\n\n- Initial release", "description_content_type": "", "docs_url": "https://pythonhosted.org/hein/", "download_url": "https://github.com/ceyzeriat/hein/tree/master/dist", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ceyzeriat/hein/", "keywords": "socket,communication,publisher,transmitter,emitter,receiver,subscriber,process,inter,interprocess", "license": "GNU General Public License v3 or later (GPLv3+)", "maintainer": "", "maintainer_email": "", "name": "hein", "package_url": "https://pypi.org/project/hein/", "platform": "", "project_url": "https://pypi.org/project/hein/", "project_urls": { "Download": "https://github.com/ceyzeriat/hein/tree/master/dist", "Homepage": "https://github.com/ceyzeriat/hein/" }, "release_url": "https://pypi.org/project/hein/0.2.3/", "requires_dist": null, "requires_python": "", "summary": "Advanced Subscriber-Publisher Socket Communication", "version": "0.2.3" }, "last_serial": 3812541, "releases": { "0.1.13": [ { "comment_text": "", "digests": { "md5": "7f8a8d58bd9d0de35f04a9fd33e31728", "sha256": "7dbb729d0bfe85a6458fc72114f261ddb120e110c7e14e7cee4baa4dc958c56d" }, "downloads": -1, "filename": "hein-0.1.13.tar.gz", "has_sig": false, "md5_digest": "7f8a8d58bd9d0de35f04a9fd33e31728", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14384, "upload_time": "2017-12-17T11:47:31", "url": "https://files.pythonhosted.org/packages/0d/6f/7c0837c16fead66e1a9febd06371d4afb68decaba3cdc0751cfa16851af0/hein-0.1.13.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "823250bb0f13e8de322a8f832b5960ce", "sha256": "585a05beb807a641172aaba3660e21bd53af8107a374d1469d35ecdc665dcf93" }, "downloads": -1, "filename": "hein-0.2.2.tar.gz", "has_sig": false, "md5_digest": "823250bb0f13e8de322a8f832b5960ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15206, "upload_time": "2018-04-26T22:27:59", "url": "https://files.pythonhosted.org/packages/b3/61/90a67d15972e51cfba7fd491bc83030f1235938c52708f7d648bdd2b1d8b/hein-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "8a94f7c57b529cda830852689bc4e287", "sha256": "0738c37bb6c0865b3405e091d0332fb08014a8714cca0aed32499277b09bd8b4" }, "downloads": -1, "filename": "hein-0.2.3.tar.gz", "has_sig": false, "md5_digest": "8a94f7c57b529cda830852689bc4e287", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15581, "upload_time": "2018-04-27T02:35:59", "url": "https://files.pythonhosted.org/packages/c2/f3/6ff8842b670abf5a7e1c03d592abe658a5bca553496e4323568c1df9e531/hein-0.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8a94f7c57b529cda830852689bc4e287", "sha256": "0738c37bb6c0865b3405e091d0332fb08014a8714cca0aed32499277b09bd8b4" }, "downloads": -1, "filename": "hein-0.2.3.tar.gz", "has_sig": false, "md5_digest": "8a94f7c57b529cda830852689bc4e287", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15581, "upload_time": "2018-04-27T02:35:59", "url": "https://files.pythonhosted.org/packages/c2/f3/6ff8842b670abf5a7e1c03d592abe658a5bca553496e4323568c1df9e531/hein-0.2.3.tar.gz" } ] }