Skip to content

Commit

Permalink
Compressed terms examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Vasiliev committed Feb 24, 2010
1 parent 178fecf commit f8a5a6d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/compression.erl
@@ -0,0 +1,16 @@
-module(compression).
-export([echo_big_data/1]).

echo_big_data(N) when N > 0 ->
Port = open_port({spawn, "python -u compression.py"},
[{packet, 4}, binary, {env, [{"PYTHONPATH", "../src"}]}]),
Big = lists:seq(0, N),
port_command(Port, term_to_binary({echo, Big}, [compressed])),
receive
{Port, {data, Data}} ->
port_close(Port),
Big = binary_to_term(Data)
after
500 ->
{error, timeout}
end.
12 changes: 12 additions & 0 deletions examples/compression.py
@@ -0,0 +1,12 @@
from erlport import Port, Protocol


class EchoProtocol(Protocol):

def handle_echo(self, data):
return data


if __name__ == "__main__":
proto = EchoProtocol()
proto.run(Port(use_stdio=True, packet=4, compressed=True))

0 comments on commit f8a5a6d

Please sign in to comment.