mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
| .. | ||
| __init__.py | ||
| __main__.py | ||
| daemon_output.py | ||
| daemon_python.py | ||
| README.md | ||
Sample usage in node.js
const cp = require('child_process');
const rpc = require('vscode-jsonrpc/node');
const env = {
PYTHONUNBUFFERED: '1',
PYTHONPATH: '<extension dir>/pythonFiles:<extension dir>/pythonFiles/lib/python'
}
const childProcess = cp.spawn('<fully qualifieid python path>', ['-m', 'vscode_datascience_helpers.daemon', '-v', '--log-file=log.log'], {env});
const connection = rpc.createMessageConnection(new rpc.StreamMessageReader(childProcess.stdout),new rpc.StreamMessageWriter(childProcess.stdin));
connection.onClose(() => console.error('Closed'));
connection.onError(ex => console.error(ex));
connection.onDispose(() => console.error('disposed'));
connection.onNotification((e, data) => console.log(`Notification from daemon, such as stdout/stderr, ${JSON.stringify(data)}`);
connection.onUnhandledNotification(e => console.error(e));
// Start
connection.listen();
const pingRequest = new rpc.RequestType('ping');
connection.sendRequest(pingRequest, {data: 'one₹😄'})
.then(response => console.log(`Pong received ${JSON.stringify(response)}`), ex => console.error(ex));