0

I am running a python script from node JS application as

const { spawnSync } = require('child_process');
const pythonProcess = await spawnSync(python3, [
  scriptFilePath,
  'methodNameToExecute',
  PathList.toString()
]);
const result = pythonProcess.stdout?.toString()?.trim();

The python script is running fine here and getting expected string output from python print method to here in result variable. But when result is too long i am getting truncated string result. Please guide me how to get full string even its too large string. Please guide if any limitation is there while passing string from python to node application.

4
  • try setting and increasing maxBuffer option, see: Stdout buffer issue using node child_process Commented Apr 29, 2024 at 12:16
  • How to set maxBuffer if i am using spawnSync method instead of exec. Can you please guide me @traynor Commented Apr 29, 2024 at 12:38
  • 1
    couldn't find more fitting answer, but spawn/spawnSync also uses that option, so it's same. try this: spawnSync(python3, [...], { maxBuffer: 10000 * 1024 }) Commented Apr 29, 2024 at 17:16
  • Thanks @traynor , I tried as you suggested and it worked for me. Thank you so much.. Commented Apr 30, 2024 at 6:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.