-
Couldn't load subscription status.
- Fork 223
Closed
Labels
Description
Describe the bug
childProcess under PythonShell.childProcess.pid is not the same pid as python os.getpid() pid
Python code
import sys
import os
class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def writelines(self, datas):
self.stream.writelines(datas)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout = Unbuffered(sys.stdout)
print(f'python pid: {os.getpid()}')Javascript code
const options = { scriptPath: 'C:\\users\\leona\\iq\\iq-websocket\\python\\botR'};
const pyTeste = new PythonShell('teste.py', options);
pyTeste
.on('message', (line: string) => {
console.log(line);
})
.on('stderr', (std: string) => {
console.log(std);
})
.on('error', err => {
console.log('err');
console.log(err);
})
.on('close', () => {
console.log('Programa finalizado');
});
console.log(`child process pid: ${pyTeste.childProcess.pid}`);Expected behavior
Both pids should be the same
Actual behavior
output:
child process pid: 52188
python pid: 40884
Other Information (please complete the following information):
- OS: Windows10
- Python Version: 3.8.7
- Node Version: 12.15.0