{ "info": { "author": "Samuel Stauffer, Basho Technologies", "author_email": "clients@basho.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Erlastic\n========\n\nUsage\n-----\n\nErlastic allows you to serialize/deserialize python objects into `erlang\nbinary term `__.\n\nBasic usage is :\n\n::\n\n import erlastic\n py_struct = erlastic.decode(binary_term)\n binary = erlastic.encode(py_struct)\n\nErlang Port communication usage\n-------------------------------\n\nThe library contains also a function to use python with erlastic in an\nerlang port to communicate erlang binary term : ``port_communication()``\nwhich return ``(mailbox,port)``. They are both python coroutines\n(executed generator) so you can communicate with erlang coroutine using\npython abstractions :\n\n- ``mailbox`` waits for port message in stdin, iterating over messages\n decoded from binary erlang term format.\n- ``port`` waits for ``send(python_struct)``\n (http://docs.python.org/3.3/reference/expressions.html#generator.send)\n then encode ``python_struct`` into binary term format and send it to\n the erlang port via stdout.\n\nSo for instance, if you want to create a Python server which receives\nthe tuple {A,B} and return {ok,A/B} of {error,divisionbyzero} you can\nuse at the python side :\n\n::\n\n from erlastic import port_connection,Atom as A\n mailbox,port = port_connection()\n\n for (a,b) in mailbox:\n port.send((A(\"ok\"),a/b) if b!=0 else (A(\"error\"),A(\"divisionbyzero\")))\n\nand at the erlang side, use ``-u`` python parameter to prevent python\noutput buffering, use 4 bytes packet length because it is the\nconfiguration used by the python generators.\n\n::\n\n Port = open_port({spawn,\"python3 -u add_server.py\"},[binary,{packet,4}]),\n Div = fun(A,B)->\n Port ! {self(),{command,term_to_binary({A,B})}},\n receive {Port,{data,Bin}}->binary_to_term(Bin) after 1000->{error,timeout} end\n end,\n io:format(\"send {A,B}=~p, python result : ~p~n\",[{32,10},Div(32,10)]),\n io:format(\"send {A,B}=~p, python result : ~p~n\",[{2,0},Div(2,0)]),\n io:format(\"send {A,B}=~p, python result : ~p~n\",[{1,1},Div(1,1)])\n\nor in elixir :\n\n::\n\n port = Port.open({:spawn,'python3 -u add_server.py'},[:binary|[packet: 4]])\n div = fn(a,b)->\n port <- {self,{:command,term_to_binary({a,b})}}\n receive do {_,{:data,b}} -> binary_to_term(b) after 100->{:error,:timeout} end\n end\n IO.puts \"send {a,b}={32,10}, python result : #{inspect div.(32,10)}\"\n IO.puts \"send {a,b}={2,0}, python result : #{inspect div.(2,0)}\"\n IO.puts \"send {a,b}={1,1}, python result : #{inspect div.(1,1)}\"", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/basho/python-erlastic", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "basho-erlastic", "package_url": "https://pypi.org/project/basho-erlastic/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/basho-erlastic/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/basho/python-erlastic" }, "release_url": "https://pypi.org/project/basho-erlastic/2.1.1/", "requires_dist": null, "requires_python": null, "summary": "Erlastic", "version": "2.1.1" }, "last_serial": 2096263, "releases": { "2.1.0": [ { "comment_text": "", "digests": { "md5": "c053588f04f44545d002abac531277d5", "sha256": "4a46f1a4cf739655caa82162562121f5ce315c89554d79db7a6fb1e697c51893" }, "downloads": -1, "filename": "basho-erlastic-2.1.0.tar.gz", "has_sig": true, "md5_digest": "c053588f04f44545d002abac531277d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9316, "upload_time": "2016-03-29T15:09:53", "url": "https://files.pythonhosted.org/packages/be/ea/466e5452e5b8b1421d8d9bb43125661b4a15ba984edd38647b00d9ed68b2/basho-erlastic-2.1.0.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "25880fdae85b0bcf8c78fe41d2236c1d", "sha256": "d1596a881437f2be71a8426efed1566b7faefb97234cb21440700ecc8367c545" }, "downloads": -1, "filename": "basho-erlastic-2.1.1.tar.gz", "has_sig": true, "md5_digest": "25880fdae85b0bcf8c78fe41d2236c1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9298, "upload_time": "2016-05-03T03:41:42", "url": "https://files.pythonhosted.org/packages/f1/2a/f1c47fa0f03f5c7ef7550d23631fe4dc904259e3a2fe8b56fa9d79be9629/basho-erlastic-2.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "25880fdae85b0bcf8c78fe41d2236c1d", "sha256": "d1596a881437f2be71a8426efed1566b7faefb97234cb21440700ecc8367c545" }, "downloads": -1, "filename": "basho-erlastic-2.1.1.tar.gz", "has_sig": true, "md5_digest": "25880fdae85b0bcf8c78fe41d2236c1d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9298, "upload_time": "2016-05-03T03:41:42", "url": "https://files.pythonhosted.org/packages/f1/2a/f1c47fa0f03f5c7ef7550d23631fe4dc904259e3a2fe8b56fa9d79be9629/basho-erlastic-2.1.1.tar.gz" } ] }