Skip to content

Commit

Permalink
add pybridge_header for future versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sylviiu committed Feb 3, 2024
1 parent c9f307c commit f29a71a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion util/pythonBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ module.exports = {
updateStatus(`Starting bridge process; this may take a bit (${currentStep}/${steps})...`)

module.exports.bridgeProc = child_process.execFile(bridgepath, {
env: { ...process.env,
PYBRIDGE_HEADER: `true`,
},
maxBuffer: 1024 * 1024 * 1024, // 1GB
});

Expand Down Expand Up @@ -193,6 +196,7 @@ module.exports = {
}

module.exports.bridgeProc.stderr.on(`data`, d => parseLog(d, `ERR`));
module.exports.bridgeProc.stdout.on(`data`, d => parseLog(d, `OUT`));

let existingData = ``;

Expand All @@ -205,15 +209,18 @@ module.exports = {

if(!data.includes(`\n\r`)) {
existingData += data;
console.log(`existingData (appended): ${existingData.length}`)
return;
} else {
if(existingData) {
data = existingData + data;
console.log(`existingData (reset): ${data.length}`)
existingData = ``;
}
} else console.log(`existingData (nothing; no reset): ${data.length}`)

const parse = (msg) => {
const data = JSON.parse(msg.toString().trim());
console.log(`bridge data for id ${data.id} (exists: ${module.exports.idHooks.find(h => h.id == data.id) ? `yes` : `no`}): [${data.type}] ${data.content.length}`);
if(data.id) {
module.exports.idHooks.filter(h => h.id == data.id).forEach(h => h.func(data));
};
Expand Down

0 comments on commit f29a71a

Please sign in to comment.