@@ -96,13 +96,13 @@ async function executeCode(code, filePath) {
9696 try {
9797 // Write code to file
9898 await writeFile ( filePath , code , 'utf-8' ) ;
99- // Get platform-specific command
100- const pythonCmd = platform ( ) === 'win32' ? `python "${ filePath } "` : `python3 "${ filePath } "` ;
99+ // Get platform-specific command with unbuffered output
100+ const pythonCmd = platform ( ) === 'win32' ? `python -u "${ filePath } "` : `python3 -u "${ filePath } "` ;
101101 const { command, options } = getPlatformSpecificCommand ( pythonCmd ) ;
102102 // Execute code
103103 const { stdout, stderr } = await execAsync ( command , {
104104 cwd : CODE_STORAGE_DIR ,
105- env : { ...process . env } ,
105+ env : { ...process . env , PYTHONUNBUFFERED : '1' } ,
106106 ...options
107107 } ) ;
108108 const response = {
@@ -136,13 +136,13 @@ async function executeCodeFromFile(filePath) {
136136 try {
137137 // Ensure file exists
138138 await access ( filePath ) ;
139- // Get platform-specific command
140- const pythonCmd = platform ( ) === 'win32' ? `python "${ filePath } "` : `python3 "${ filePath } "` ;
139+ // Get platform-specific command with unbuffered output
140+ const pythonCmd = platform ( ) === 'win32' ? `python -u "${ filePath } "` : `python3 -u "${ filePath } "` ;
141141 const { command, options } = getPlatformSpecificCommand ( pythonCmd ) ;
142- // Execute code
142+ // Execute code with unbuffered Python
143143 const { stdout, stderr } = await execAsync ( command , {
144144 cwd : CODE_STORAGE_DIR ,
145- env : { ...process . env } ,
145+ env : { ...process . env , PYTHONUNBUFFERED : '1' } ,
146146 ...options
147147 } ) ;
148148 const response = {
@@ -309,10 +309,10 @@ async function installDependencies(packages) {
309309 }
310310 // Get platform-specific command
311311 const { command, options } = getPlatformSpecificCommand ( installCmd ) ;
312- // Execute installation
312+ // Execute installation with unbuffered Python
313313 const { stdout, stderr } = await execAsync ( command , {
314314 cwd : CODE_STORAGE_DIR ,
315- env : { ...process . env } ,
315+ env : { ...process . env , PYTHONUNBUFFERED : '1' } ,
316316 ...options
317317 } ) ;
318318 const response = {
@@ -407,12 +407,12 @@ for package in ${JSON.stringify(packages)}:
407407print(json.dumps(results))
408408` ;
409409 await writeFile ( checkScriptPath , checkScript , 'utf-8' ) ;
410- // Execute the check script
411- const pythonCmd = platform ( ) === 'win32' ? `python "${ checkScriptPath } "` : `python3 "${ checkScriptPath } "` ;
410+ // Execute the check script with unbuffered output
411+ const pythonCmd = platform ( ) === 'win32' ? `python -u "${ checkScriptPath } "` : `python3 -u "${ checkScriptPath } "` ;
412412 const { command, options } = getPlatformSpecificCommand ( pythonCmd ) ;
413413 const { stdout, stderr } = await execAsync ( command , {
414414 cwd : CODE_STORAGE_DIR ,
415- env : { ...process . env } ,
415+ env : { ...process . env , PYTHONUNBUFFERED : '1' } ,
416416 ...options
417417 } ) ;
418418 if ( stderr ) {
0 commit comments