Created
May 26, 2017 15:45
-
-
Save chrisortman/b620399670d033cb2fcf5f0ebf9bc2ee to your computer and use it in GitHub Desktop.
Streaming external program output in elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
from time import sleep | |
defaults = [ | |
"Output", | |
30, | |
.25 | |
] | |
for index, arg in enumerate(argv[1:]): | |
defaults[index] = arg | |
print "Executing with options %s" % defaults | |
text = defaults[0] | |
num = int(defaults[1]) | |
seconds = float(defaults[2]) | |
for i in range(0,num): | |
print "%s %d" % (text, i) | |
sleep(seconds) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.cmd "python", ["-u", "long_run.py"], into: IO.stream(:stdio, :line) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment