7

Possible Duplicate:
best way to integrate erlang and python

To use some powerful features of erlang, I should call erlang program from Python, How can I do that? Thank you~

Community
  • 1
  • 1
Suge
  • 2,808
  • 3
  • 48
  • 79
  • Can you provide a description of the problem you are trying to solve? I'm struggling to think of a valid use-case for an Erlang application being managed by a Python app. What powerful features are you referring too? – dsmith Dec 15 '10 at 20:52

3 Answers3

8

In Erlang , you can communicate with the external world using ports which provides a byte oriented interface to the external program.

You can also have a look at erlport which is a python library implementing the Erlang port protocol.

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
Arunmu
  • 6,837
  • 1
  • 24
  • 46
  • I'v found the way to call python from erlang, but I don't know how to call erlang fron python.Even the erlport, looks only supply the way to call python from erlang. – Suge Dec 13 '10 at 03:48
  • ok. Another thing what you can try is to run the Erlang Virtual machine as a daemon using the "runerl" command. This will create two named pipes in "/tmp" for reading and writing purpose (erlang.pipe.1.r And erlang.pipe.1.w) . Using python you can write the command(as you use in erlang command line) to the named pipe , the VM will execute it and you can fetch the output from the read named pipe. Hope this is what you need . – Arunmu Dec 13 '10 at 04:04
3

Take a look at BERT-RPC. It allows you to perform remote procedure calls and casts, request data (including streaming). There you'll find various libraries for some languages including Python.

In your case you might just set up erlang server using ernie and communicate with it via python-bertrpc client. Both projects are documented.

YasirA
  • 9,531
  • 2
  • 40
  • 61
1

We mostly use JSON over HTTP to do this. In some cases you might want to use a more robust messaging protocol (e.g. AMQP with RabbitMQ), but there's rarely a good reason for Python to directly speak the Erlang distribution protocol. Sometimes we use erlport to serialize things instead of JSON, when performance is a little more important.