Permalink
Browse files

Compressed terms examples

  • Loading branch information...
1 parent 178fecf commit f8a5a6de06ea7c837d4172f6079e6bde64d1d5e2 Dmitry Vasiliev committed Feb 24, 2010
Showing with 28 additions and 0 deletions.
  1. +16 −0 examples/compression.erl
  2. +12 −0 examples/compression.py
View
16 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.
View
12 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.