classification
Title: Python/pystate.c:561 :PyGILState: The assertion 'autoInterpreterState' has failed
Type: resource usage Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, brett.cannon, lcarrionr
Priority: normal Keywords:

Created on 2008-11-26 19:41 by lcarrionr, last changed 2008-11-27 15:07 by amaury.forgeotdarc. This issue is now closed.

Files
File name Uploaded Description Edit
unnamed lcarrionr, 2008-11-27 11:59
unnamed lcarrionr, 2008-11-27 14:41
Messages (7)
msg76484 - (view) Author: LuisC (lcarrionr) Date: 2008-11-26 19:41
The project goal is to incorporate the functionality of interaction of 
the excel application (gnumeric) with the XO's journal. All the 
activities needs to register any change in that datastore (save and 
open files are made throw it). 

In order to apply this option, we need to call some python code from 
the implementation of the worksheet in C code. This is called embedded 
python in C. The steps followed to accomplish this goal came from the 
OLPC site recomendations, in wiki.laptop.org. The python script for the 
interaction with the journal's datastore can be found in here: 
http://wiki.laptop.org/go/Copy_to_and_from_the_Journal 

The changes in the gnumeric code are basically in the workbook-view.c 
and main-application.c to handle the open and save options. In the main-
application.c the method gui_file_copy_from_journal uses the python 
api/c to make the call to the journal script. after this method and 
during the open of the file, an exception rises. Although we are not 
sure, we believe it has to do with the closure of the python enviroment 
after the finalize call. We need to erase this exception or may be just 
handle it. 

The error running in the XO is: 

gnumeric: Python/pystate.c:561 :PyGILState: The 
assertion 'autoInterpreterState' has failed 

The configuration of the XO where we are getting the exception is: 

Python 2.5 (r25:51908, Oct 19 2007, 09:47:40) [gcc 4.1.2 20070925 (Red 
Hat 4.1.2-27)] on linux2 

Any help is greatly appreciated!!!
msg76487 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-11-26 19:52
Is this an actual bug report or more of a request for help? If it is the
former then a test case is needed in order to help figure out what is
going on. If it is the latter you should ask on
comp.lang.python/python-list.
msg76488 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-11-26 19:59
Also, please do not add everyone in the project to the nosy list.
msg76491 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-27 09:22
The assertion is clear if you open the source code (Python/pystate.c,
line 561):

assert(autoInterpreterState); /* Py_Initialize() hasn't been called! */

Does your code make sure that the python interpreter is initialized?
msg76493 - (view) Author: LuisC (lcarrionr) Date: 2008-11-27 11:59
Hi Amaury, thanks for you response...

This is my code sniped

gboolean
gui_file_copy_to_journal(char const *uri)
{
        g_printerr("SAVING PYTHON JOURNAL!...........%s\n", uri);

        char * arg1[7];

        arg1[0] = "python";
        arg1[1] = "/home/olpc/copy-to-Journal.py"; 
        arg1[2] = uri+7;
        arg1[3] = "-d";
        arg1[4] = "hoja_de_calculo"; 
        arg1[5] = "-m";
        arg1[6] = "application/x-gnumeric"; 

        g_printerr ("Writing py \n");
        Py_Initialize(); 
        Py_Main(7, arg1);
        Py_Finalize();
        g_printerr ("Writing Py_Finalize \n");

        return TRUE;
}

also, I tried with other method like linux journal show in 
http://www.linuxjournal.com/article/3641

Any help is greatly appreciated...

Luis Carrión
Tata Consultancy Services
Colonia 1329-Piso 3
Montevideo,.
Uruguay
Mailto: luis.carrion@tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty.   IT Services
                        Business Solutions
                        Outsourcing
____________________________________________

Amaury Forgeot d'Arc <report@bugs.python.org> 
27/11/2008 07:22 a.m.
Please respond to
Python tracker <report@bugs.python.org>

To
luis.carrion@tcs.com
cc

Subject
[issue4443] Python/pystate.c:561 :PyGILState: The assertion 
'autoInterpreterState' has failed

Amaury Forgeot d'Arc <amauryfa@gmail.com> added the comment:

The assertion is clear if you open the source code (Python/pystate.c,
line 561):

assert(autoInterpreterState); /* Py_Initialize() hasn't been called! */

Does your code make sure that the python interpreter is initialized?

----------
nosy: +amaury.forgeotdarc

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4443>
_______________________________________

ForwardSourceID:NT0000A7E6 
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you
msg76494 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-27 12:11
> Py_Initialize(); 
> Py_Main(7, arg1);
> Py_Finalize();

This seems correct... unless two threads run this function at the same
time. Can you ensure that this is not the case?

It seems to me that a simple call to 
   system("python /home/olpc/copy-to-Journal.py [other-args-here]") 
would be better...
msg76501 - (view) Author: LuisC (lcarrionr) Date: 2008-11-27 14:41
Thank you so much. It do worked!

I don't think two threads to be running the same function because the 
messages are displayed only once.
Yes it seems to be a better way it worked, thank you again.

Regards, 

Luis Carrión
Tata Consultancy Services
Colonia 1329-Piso 3
Montevideo,.
Uruguay
Mailto: luis.carrion@tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty.   IT Services
                        Business Solutions
                        Outsourcing
____________________________________________

Amaury Forgeot d'Arc <report@bugs.python.org> 
27/11/2008 10:11 a.m.
Please respond to
Python tracker <report@bugs.python.org>

To
luis.carrion@tcs.com
cc

Subject
[issue4443] Python/pystate.c:561 :PyGILState: The assertion 
'autoInterpreterState' has failed

Amaury Forgeot d'Arc <amauryfa@gmail.com> added the comment:

> Py_Initialize(); 
> Py_Main(7, arg1);
> Py_Finalize();

This seems correct... unless two threads run this function at the same
time. Can you ensure that this is not the case?

It seems to me that a simple call to 
   system("python /home/olpc/copy-to-Journal.py [other-args-here]") 
would be better...

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue4443>
_______________________________________

ForwardSourceID:NT0000A982 
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you
History
Date User Action Args
2008-11-27 15:07:12amaury.forgeotdarcsetstatus: open -> closed
resolution: not a bug
2008-11-27 14:41:27lcarrionrsetfiles: + unnamed
messages: + msg76501
2008-11-27 12:11:33amaury.forgeotdarcsetmessages: + msg76494
2008-11-27 11:59:37lcarrionrsetfiles: + unnamed
messages: + msg76493
2008-11-27 09:22:44amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg76491
2008-11-26 20:00:06benjamin.petersonsetnosy: - benjamin.peterson
2008-11-26 19:59:41benjamin.petersonsetnosy: + benjamin.peterson, - mwh, lemburg, gvanrossum, barry, doerwalter
messages: + msg76488
2008-11-26 19:52:38brett.cannonsetmessages: + msg76487
2008-11-26 19:41:37lcarrionrcreate