Last active
August 5, 2016 18:44
-
-
Save haniawni/e70c66ecd5065ed4b6fcdbefeecf5e5f to your computer and use it in GitHub Desktop.
Test code for issue https://github.com/extrabacon/python-shell/issues/51
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
pys = require('python-shell'); | |
sl = require('sleep'); | |
var s = new pys('testStdIn.py'); | |
s.on('message',function(message){ | |
console.log('stdOut: '+ message); | |
}); | |
s.on('error',function(message){ | |
console.log('stdErr: '+ message); | |
}); | |
while(true){ | |
str = (Math.random()*10).toString()+' lol'; | |
console.log('Sending: '+str) | |
s.send(str); | |
sl.sleep(1); | |
} |
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
var spawn = require('child_process').spawn, | |
sl = require('sleep'); | |
s = spawn('python',['testStdIn.py']); | |
s.on('data',function(message){ | |
console.log('stdOut: '+ message); | |
}); | |
while(true){ | |
str = (Math.random()*10).toString()+' lol'; | |
console.log('Sending: '+str) | |
s.stdin.write(str); | |
sl.sleep(1); | |
} |
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 __future__ import print_function | |
import sys | |
import time | |
from datetime import datetime | |
import thread | |
def eprint(*args, **kwargs): | |
print(*args, file=sys.stderr, **kwargs) | |
def spamSTDErr(): | |
while(True): | |
eprint('e: '+str(datetime.now())) | |
time.sleep(2) | |
thread.start_new_thread(spamSTDErr,()) | |
while(True): | |
s = raw_input() | |
print('o: '+s + " GONNA GIVE IT TO YA") |
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 __future__ import print_function | |
import sys | |
import time | |
from datetime import datetime | |
import thread | |
from pylsl import StreamInfo, StreamOutlet | |
def eprint(*args, **kwargs): | |
print(*args, file=sys.stderr, **kwargs) | |
def spamSTDErr(): | |
while(True): | |
eprint('e: '+str(datetime.now())) | |
time.sleep(2) | |
info = StreamInfo('Handoff', 'Test', 1, 0, 'string', '8265817653173') | |
lslo = StreamOutlet(info) | |
thread.start_new_thread(spamSTDErr,()) | |
while(True): | |
s = raw_input() | |
lslo.push_sample(s) | |
print('o: '+s + " GONNA GIVE IT TO YA") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment