Supervising Python processes from Elixir

My Elixir project must rely on PyWaves, a Python library, to execute trades. Erlport and Pyrlang looked like attractive solutions for reliable connectivity between the two but, after further inspection, it appears both projects have been abandoned.

gRPC seems to be a viable alternative but before going down that rabbit hole I have to ask, are there any actively maintained libraries that offer simple, featherweight, direct solutions to establishing, maintaining and monitoring communications between Elixir and Python codebases running on the same machine?

You can use regular ports (Erlport is just wrapper on top of that) or C-Nodes.

2 Likes

This is a great article showing exactly what it means to use ports to connect Elixir & Python (for a different use case): https://www.poeticoding.com/real-time-object-detection-with-phoenix-and-python/

3 Likes

@hauleth @mindok

Thank you both for your recommendations! :slight_smile:

Now, it seems that it’s possible to supervise multiple, concurrent instances of a Python process by simply assigning a distinct port to each one or am I mistaken?

I believe so - a single Elixir process can control multiple ports, and you can obviously also have multiple processes controlling one or more ports.

Also, another article that is worth reading is https://www.theerlangelist.com/article/outside_elixir

1 Like

Shameless plug: there is a small Python library called erlastic that handles the conversion between Erlang’s and Python’s internal encoding of strings, numbers, objects etc. It’s not mine but I maintain a fork here which AFAIK is the most up-to-date version. I’ve been using this thing with ports for years – I outsource numerical computation jobs to Python scripts, and it works great.

6 Likes

Thanks for the recommendation, I’ll definitely check it out! It seems the readme doesn’t have install instructions/requirements. Where do I find these?

Sorry, good question! I should put it on PyPi. You should be able to install it directly from Github though; I simply use pip3 install git+https://github.com/skosch/python-erlastic.

2 Likes

Gotcha, thanks!