Since I didn't get a response, I will post again with a more appropiate subject heading. If you run the following code, you get an error. It appears that Numpy doesn't like to be restarted. If you take out the lines "import_array();" and "PyRun_SimpleString("from Numeric import *\n");" the code loops fine.
for (int x = 0; x < 100; x++) { Py_Initialize(); import_array(); PyRun_SimpleString("from Numeric import *\n"); TRACE("%d\n",x); Py_Finalize(); }
Here is the output: 0 1 Fatal Python error: UNREF invalid object
The import_array is not proper, but I have no idea if that is the problem or not. import array only goes in the initialization routine of modules that need the Numpy CAPI.
Somebody convinced me to decref something in one of the numpy C module initializers a while back, so maybe that was an error. (?) I just do what they tell me...
Original Message From: numpydiscussionadmin@lists.sourceforge.net [mailto:numpydiscussionadmin@lists.sourceforge.net]On Behalf Of Karl Bellve Sent: Thursday, May 10, 2001 5:57 AM To: Numpy Subject: [Numpydiscussion] Numpy bug?
Since I didn't get a response, I will post again with a more appropiate subject heading. If you run the following code, you get an error. It appears that Numpy doesn't like to be restarted. If you take out the lines "import_array();" and "PyRun_SimpleString("from Numeric import *\n");" the code loops fine.
for (int x = 0; x < 100; x++) { Py_Initialize(); import_array(); PyRun_SimpleString("from Numeric import *\n"); TRACE("%d\n",x); Py_Finalize(); }
Here is the output: 0 1 Fatal Python error: UNREF invalid object
 Cheers,
Karl Bellve
_______________________________________________ Numpydiscussion mailing list Numpydiscussion@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpydiscussion
How can we correct this error?
Otherwise, Numpy can only be initialized once per application/thread?
Here is what I do, a user loads an image into my application, then runs a Python script. I do a Py_Initialize(), initialize Numpy, initialize my module, run the script and finally Py_Finalize(). Each image can do this. My module only knows about its own image and can run a python script multiple times.
So, if I have to make it more global, I would have to run Py_Intialize/Py_Finalize once per application. Redesign my module so that a user must pick the specific image to work on. Redesign the scripts so that a user must transverse all the images to the correct image. Hey, I would rather fix numpy so it can be initialized multiple times. Do you remember why the person wanted to do that? Or, if you let me know where you did that, I can fix it in my local source instead.
"Paul F. Dubois" wrote:
The import_array is not proper, but I have no idea if that is the problem or not. import array only goes in the initialization routine of modules that need the Numpy CAPI.
Somebody convinced me to decref something in one of the numpy C module initializers a while back, so maybe that was an error. (?) I just do what they tell me...
Original Message From: numpydiscussionadmin@lists.sourceforge.net [mailto:numpydiscussionadmin@lists.sourceforge.net]On Behalf Of Karl Bellve Sent: Thursday, May 10, 2001 5:57 AM To: Numpy Subject: [Numpydiscussion] Numpy bug?
Since I didn't get a response, I will post again with a more appropiate subject heading. If you run the following code, you get an error. It appears that Numpy doesn't like to be restarted. If you take out the lines "import_array();" and "PyRun_SimpleString("from Numeric import *\n");" the code loops fine.
for (int x = 0; x < 100; x++) { Py_Initialize(); import_array(); PyRun_SimpleString("from Numeric import *\n"); TRACE("%d\n",x); Py_Finalize(); }
Here is the output: 0 1 Fatal Python error: UNREF invalid object
 Cheers,
Karl Bellve
participants (2)

Karl Bellve

Paul F. Dubois