Created
November 18, 2018 21:20
-
-
Save zcaceres/03a30ca653e7f7a9f1d42b9f623ee7fd to your computer and use it in GitHub Desktop.
Sample 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
class PythonConnector { | |
static server() { | |
if (!PythonConnector.connected) { | |
console.log('PythonConnector – making a new connection to the python layer'); | |
PythonConnector.zerorpcProcess = spawn('python3', ['-u', path.join(__dirname, 'PythonServer.py')]); | |
PythonConnector.zerorpcProcess.stdout.on('data', function(data) { | |
console.info('python:', data.toString()); | |
}); | |
PythonConnector.zerorpcProcess.stderr.on('data', function(data) { | |
console.error('python:', data.toString()); | |
}); | |
PythonConnector.zerorpc = new zerorpc.Client({'timeout': TIMEOUT, 'heartbeatInterval': TIMEOUT*1000}); | |
PythonConnector.zerorpc.connect('tcp://' + IP + ':' + PORT); | |
PythonConnector.connected = true; | |
} | |
return PythonConnector.zerorpc; | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment