Use of Subprocess python module in programmable filter to print output from Shell script

Hello, I’m trying develop a plugin (python programmable filter using util.vtkAlgorithm module) to use one of my existing program to do some processing. I would like the python script can display the output in the output message window from my program (which is a compiled c++ program, run by using a shell command using subprocess.Popen), however, it seems working fine except, I can see any output in output message window, I’m wondering if there is anything I’m doing wrong… Here is the method I used in RequestData Function:

Thank you very much!

def RequestData(self, request, inInfoVec, outInfoVec):

    shell = 'mpirun --oversubscribe -np '+str(self._mpi_x*self._mpi_y*self._mpi_z)+' '+self._mpiexacutable+' '+'mesh_input.dat'
    r = subprocess.Popen(shell.split(), 
                        stdout=subprocess.PIPE,
                        stderr=subprocess.STDOUT,
                        bufsize=0)
    while r.poll() is None:
        line = str(r.stdout.readline(), encoding='utf-8')
        line = line.strip()

    if line:
        print('Subprogram output: [{}]'.format(line))

    out_new_vtk = self._filename.split('/')[-1] + '_new_mesh'+str(self._AMRSteps)+'.vtk'
    
    new_mesh_vtk = LegacyVTKReader(registrationName=out_new_vtk, FileNames=[self._filename+'_new_mesh'+str(self._AMRSteps)+'.vtk'])
    new__mesh_vtkDisplay = Show(new_mesh_vtk, renderView1, 'UniformGridRepresentation')
    

    return 1