FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

childProcess pid is not the same pid as python pid · Issue #236 · extrabacon/python-shell · GitHub

Repository navigation

childProcess pid is not the same pid as python pid #236

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL