Skip to content

Commit fdcc3ba

Browse files
jefcodercforge42
authored andcommitted
buffering issue solved
1 parent 9f2e3ad commit fdcc3ba

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

build/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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)}:
407407
print(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) {

src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ async function executeCode(code: string, filePath: string) {
116116
// Write code to file
117117
await writeFile(filePath, code, 'utf-8');
118118

119-
// Get platform-specific command
120-
const pythonCmd = platform() === 'win32' ? `python "${filePath}"` : `python3 "${filePath}"`;
119+
// Get platform-specific command with unbuffered output
120+
const pythonCmd = platform() === 'win32' ? `python -u "${filePath}"` : `python3 -u "${filePath}"`;
121121
const { command, options } = getPlatformSpecificCommand(pythonCmd);
122122

123123
// Execute code
124124
const { stdout, stderr } = await execAsync(command, {
125125
cwd: CODE_STORAGE_DIR,
126-
env: { ...process.env },
126+
env: { ...process.env, PYTHONUNBUFFERED: '1' },
127127
...options
128128
});
129129

@@ -161,14 +161,14 @@ async function executeCodeFromFile(filePath: string) {
161161
// Ensure file exists
162162
await access(filePath);
163163

164-
// Get platform-specific command
165-
const pythonCmd = platform() === 'win32' ? `python "${filePath}"` : `python3 "${filePath}"`;
164+
// Get platform-specific command with unbuffered output
165+
const pythonCmd = platform() === 'win32' ? `python -u "${filePath}"` : `python3 -u "${filePath}"`;
166166
const { command, options } = getPlatformSpecificCommand(pythonCmd);
167167

168-
// Execute code
168+
// Execute code with unbuffered Python
169169
const { stdout, stderr } = await execAsync(command, {
170170
cwd: CODE_STORAGE_DIR,
171-
env: { ...process.env },
171+
env: { ...process.env, PYTHONUNBUFFERED: '1' },
172172
...options
173173
});
174174

@@ -351,10 +351,10 @@ async function installDependencies(packages: string[]) {
351351
// Get platform-specific command
352352
const { command, options } = getPlatformSpecificCommand(installCmd);
353353

354-
// Execute installation
354+
// Execute installation with unbuffered Python
355355
const { stdout, stderr } = await execAsync(command, {
356356
cwd: CODE_STORAGE_DIR,
357-
env: { ...process.env },
357+
env: { ...process.env, PYTHONUNBUFFERED: '1' },
358358
...options
359359
});
360360

@@ -456,13 +456,13 @@ print(json.dumps(results))
456456

457457
await writeFile(checkScriptPath, checkScript, 'utf-8');
458458

459-
// Execute the check script
460-
const pythonCmd = platform() === 'win32' ? `python "${checkScriptPath}"` : `python3 "${checkScriptPath}"`;
459+
// Execute the check script with unbuffered output
460+
const pythonCmd = platform() === 'win32' ? `python -u "${checkScriptPath}"` : `python3 -u "${checkScriptPath}"`;
461461
const { command, options } = getPlatformSpecificCommand(pythonCmd);
462462

463463
const { stdout, stderr } = await execAsync(command, {
464464
cwd: CODE_STORAGE_DIR,
465-
env: { ...process.env },
465+
env: { ...process.env, PYTHONUNBUFFERED: '1' },
466466
...options
467467
});
468468

0 commit comments

Comments
 (0)