Skip to main content

Erlang port protocol

Project description

Erlang port protocol for Python simplify interoperability between Erlang and Python. On the Python side write a processor object and pass it to erlport.PortProtocol like this:

from erlport import PortProtocol

class Processor(object):

    def hello(self, name):
        return "Hello, %s" % name

if __name__ == "__main__":
    PortProtocol(Processor()).start()

On the Erlang side function hello() can be called like this:

-module(hello).
-export([hello/1]).

hello(Name) ->
    Port = open_port({spawn, "python hello.py"},
        [{packet, 1}, nouse_stdio, binary]),
    port_command(Port, term_to_binary({hello, Name})),
    receive
        {Port, {data, Data}} ->
            binary_to_term(Data)
    end.

Test it in the Erlang shell:

1> c(hello).
{ok,hello}
2> hello:hello("Bob").
"Hello, Bob"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erlport-0.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

erlport-0.2-py2.6.egg (10.5 kB view details)

Uploaded Egg

File details

Details for the file erlport-0.2.tar.gz.

File metadata

  • Download URL: erlport-0.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for erlport-0.2.tar.gz
Algorithm Hash digest
SHA256 594d51c39d308c8abcde08a55682003e40a936132779ebf970aa9a6008217f3d
MD5 15fb73488372519d59853d06d889a901
BLAKE2b-256 52d404f728fc1c2e0d530d69dccc3d63be3b5e498c971040d5d103d48bb45853

See more details on using hashes here.

File details

Details for the file erlport-0.2-py2.6.egg.

File metadata

  • Download URL: erlport-0.2-py2.6.egg
  • Upload date:
  • Size: 10.5 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for erlport-0.2-py2.6.egg
Algorithm Hash digest
SHA256 256482b4d9a5db7d2e4af057b2562bc452fad01947936c5eb81db498a9139a92
MD5 b3ca55d641ce903a1169d2f6ebada91e
BLAKE2b-256 e4de476bcff844b90d0a853130de8579cfa94457a5b4100568e4c28c9cb55043

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page