Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple port example #2

Merged
merged 3 commits into from
Jul 27, 2016
Merged

Add a simple port example #2

merged 3 commits into from
Jul 27, 2016

Conversation

artob
Copy link
Contributor

@artob artob commented Jul 26, 2016

This pull request adds a basic example of interprocess communication between Elixir and Python scripts using an Erlang port and the Erlang external term format.

Running examples/test.exs will spawn examples/port.py as a port subprocess that will echo back any Erlang term sent to the port, in the examples/test.exs example the single-atom tuple {ping}.

@okeuday
Copy link
Owner

okeuday commented Jul 26, 2016

@bendiken Thank you for the contribution! Can you please tweak it to use nouse_stdio in the erlang:open_port/2 settings, and then use os.fdopen(3) and os.fdopen(4) in the python code without having stream have a default argument in the functions that take stream. That should help simplify the example. Then, the python try/except can be removed to make sure errors can output normally. Also, please indent the python with 4 spaces, to make that a more typical format (2 spaces is typical in elixir, so the elixir indent is good).

@artob
Copy link
Contributor Author

artob commented Jul 27, 2016

@okeuday Thanks for the feedback. I've applied the changes you requested. You were right that nouse_stdio simplified the example nicely. Hopefully this is good to merge now?

PS. I've tested the example with both Python 2.7 and Python 3.5. (Elixir 1.3 in both cases.)

@okeuday okeuday merged commit 94bd0f4 into okeuday:master Jul 27, 2016
@okeuday
Copy link
Owner

okeuday commented Jul 27, 2016

@bendiken Looks good. Thanks for adding this example!

@artob artob deleted the examples branch July 27, 2016 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants