473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

invoking interpeter in another interpeter

Hi

I have extended/embedded python into my application, it is working
great, The documentation is too good,
I could replace existing scripting tool to python in no time.
I have one problem with invoking python interpreter from another python
interpreter.
This is how it is.

I have one C API which executes python interpreter passing the file name,
So there are chances that in that file one command it self is the API to
execute python.
It is hanging in the second invocation, could some one help.

Thanks in advance
Anand
-------------------------------------------------------------------
Python code:

First python file

from Vdb import *
# This is the invocation of another python interpeter from one
ExecutePythonInterpeter("another.py" )
The application first calls the ExecutePythonInterpter C API, which in
turn calls same API for different file,
from python,

Following is the C implementation of ExecutePythonInterpeter.

void ExecutePythonInterpeter(
char *file
)
{
FILE *fp;
char *msg ;
PyObject *exc, *val, *trb, *obj ;
PyThreadState *gtstate = NULL;

if( Py_IsInitialized() == FALSE)
{
Py_Initialize();
PyEval_InitThreads();
gtstate = PyEval_SaveThread();
}
ExecutePythonInterpeterThread(file);
if(gtstate)
{
PyEval_AcquireThread(gtstate);
Py_Finalize();
gtstate=NULL;
}
return ;
}

void ExecutePythonInterpeterThread(
char *file
)
{
FILE *fp;
char file_name[256] ;
PyThreadState *tstate ;
PyEval_AcquireLock();
tstate = Py_NewInterpreter();
initVdb();
initVdbPythonVgPoint2() ;
initVdbPythonVgPoint3();
if(tstate == NULL) {
fprintf(stderr, "Can't create an interpreter\n");
return ;
}
sprintf(file_name,"%s",file);
fp=fopen(file_name,"r");
if(!fp)
{
fprintf(stderr,"FATAL:File open for %s failed\n",file);
return ;
}
PyRun_SimpleFile(fp,file_name) ;
Py_EndInterpreter(tstate);
PyEval_ReleaseLock();
fclose(fp);
return ;
}

Jul 18 '05 #1
0 1082

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: DJ Craig | last post by:
I use a web hosting service that gives me FTP access to my directory on a Linux server. I use Mac OS X. I write my code in Dreamweaver MX which gives me color-coding, but I get really tired of...
0
by: Prasad | last post by:
We are invoking a SQL DTS component (lets call it Comp1) built by us in another component (Comp2).Comp1 was built by creating the DTS package using the SQL DTS wizard and then saving it as a VB...
13
by: Patrick | last post by:
I understand that with IIS5.1 on Windows XP Professional SP1, I can 1) Either set under IIS Manager-> Any specific Virtual Directory-> Configuration->Options->ASP Script timeout for all pages...
25
by: MuZZy | last post by:
Hi, I'm currently rewriting some functionality which was using multithredaing for retrieving datasets from database and updating a grid control. I found that the grids (Infragistics UltraGrid,...
2
by: Jack | last post by:
I want to design a server which performs some business related user authentiation, and would like to let the clients invoke it through webservice, so my first thinking is using IIS as the web...
3
by: Paul | last post by:
I have a problem of invoking my C# DLL from my VBA code. I have created the C# component, my code is looking like this: public class Class1 { public Class1() { } public int TestMethod(int i,...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
1
by: Suds | last post by:
Hi, I'm having an issue with invoking a Generic method that takes Generic Arguments. My method signature is public void GenericMethodWithGenericArguments<E, V>(List<EtheFirstList,...
2
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.