Bruce,

Try the attached patch. You'll need to apply it to the VTK subdir
under ParaView.

Utkarsh

On Tue, May 26, 2015 at 11:29 AM, Bruce Jones
<[email protected]> wrote:
> Hi,
>
> I am trying to do some parallel programming within paraviews python shell
> and have encountered a problem. If I run the following two lines of code in
> the python shell, the result is that a whole bunch of new paraview sessions
> will be started...
>
> from multiprocessing import Pool
> pool = Pool();
>
> It appears that a new paraview session is being created for each thread of
> the thread pool. Unfortunately, I am not able to then use the thread pool to
> run functions assynchronously.
>
> Regards,
> Bruce
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
diff --git a/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h b/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
index 43000d3..f0b1bc4 100644
--- a/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
+++ b/Utilities/PythonInterpreter/vtkPythonStdStreamCaptureHelper.h
@@ -54,17 +54,24 @@ struct vtkPythonStdStreamCaptureHelper
     {
     return vtkPythonInterpreter::ReadStdin();
     }
+
+  void Close()
+    {
+    this->Flush();
+    }
 };
 
 static PyObject* vtkWrite(PyObject* self, PyObject* args);
 static PyObject* vtkRead(PyObject* self, PyObject* args);
 static PyObject* vtkFlush(PyObject* self, PyObject* args);
+static PyObject* vtkClose(PyObject* self, PyObject* args);
 
 // const_cast since older versions of python are not const correct.
 static PyMethodDef vtkPythonStdStreamCaptureHelperMethods[] = {
     {const_cast<char*>("write"), vtkWrite, METH_VARARGS, const_cast<char*>("Dump message")},
     {const_cast<char*>("readline"), vtkRead, METH_VARARGS, const_cast<char*>("Read input line")},
     {const_cast<char*>("flush"), vtkFlush, METH_VARARGS, const_cast<char*>("Flush")},
+    {const_cast<char*>("close"), vtkClose, METH_VARARGS, const_cast<char*>("Close and Flush")},
     {0, 0, 0, 0}
 };
 
@@ -191,6 +198,23 @@ static PyObject* vtkFlush(PyObject* self, PyObject* args)
   return Py_BuildValue(const_cast<char*>(""));
 }
 
+static PyObject* vtkClose(PyObject* self, PyObject* args)
+{
+  (void)args;
+  if(!self || !PyObject_TypeCheck(self, &vtkPythonStdStreamCaptureHelperType))
+    {
+    return 0;
+    }
+
+  vtkPythonStdStreamCaptureHelper* wrapper =
+    reinterpret_cast<vtkPythonStdStreamCaptureHelper*>(self);
+  if (wrapper)
+    {
+    wrapper->Close();
+    }
+  return Py_BuildValue(const_cast<char*>(""));
+}
+
 static vtkPythonStdStreamCaptureHelper* NewPythonStdStreamCaptureHelper(bool for_stderr=false)
 {
   if(PyType_Ready(&vtkPythonStdStreamCaptureHelperType) < 0)
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to