472,342 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

A problem in embedding Python in a plug-in

Hi, I'm now making a plug-in for a CG software. I embed
Python in a plugin and it works. The problem is that it
conflicts with other plugins that also embeds Python because it
runs in the same thread. I don't know when Py_Initialize() and
Py_Finalize() are executed because I don't know when user loads/unloads
a plugin that embeds Python. Is there any right way to embed
Python in a plug-in under the following conditions? If not, what
options do I have to give up any of them?

- My plug-in has no way to know when the user loads/unloads it.
- My plug-in has no way to know when the user loads/unloads somebody
else's plug-in that embeds Python.
- Somebody else's plug-in might have used any Python/C API including
GIL related stuff, new_interpreter, PyGILState_*
- Every plug-in initially runs in the same thread but some plug-in
can start a new thread.
- Preferably my plug-in has its own __main__
- My plug-in doesn't have to be thread safe but shouldn't disturb
any other plug-in (so should be thread safe anyway)

Typical problem is:
- When somebody else loads or unloads another plugin and calls
Py_IsInitialized() or Py_Finalize(), my plugin fails
- When some other plugin uses PyGILState*(), both plugin fails
because my plug-in uses new interpreter
(I'm new to Python/C API so I may be misunderstanding one ore more)

Any suggestion is appreciated.

Koichi
Jan 6 '07 #1
1 1229
On 6 ene, 15:29, Koichi <kotam...@hello.email.ne.jpwrote:
Hi, I'm now making a plug-in for a CG software. I embed
Python in a plugin and it works. The problem is that it
conflicts with other plugins that also embeds Python because it
runs in the same thread. I don't know when Py_Initialize() and
Given all those constraints, I think the only safe option is to run
Python in another process.
You write a very simple plugin (NOT in Python, maybe C code) that
spawns another process (the actual Python code) and forwards all
requests to that other process, using some form of IPC.

--
Gabriel Genellina

Jan 7 '07 #2

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

Similar topics

0
by: soso | last post by:
Hello everybody, Is there a nice helper tool for easier embedding of python code? Like SWIG helps extending python. Thanks, soso
2
by: mike | last post by:
Hi All, I have some "new-style" classes written in Python that I would like to embed inside a C++ application (somewhat grudgingly - if I had my...
9
by: Carl | last post by:
I have been using Python for quite some time now and I love it. I use it mainly for explorative computing and numerical prototyping, ie testing and...
0
by: adsheehan | last post by:
Hi, I am embedding Python into a multi-threaded C++ application runnig on Solaris and need urgent clarification on the embedding architecture and...
0
by: adsheehan | last post by:
Hi, I am embedding Python into a multi-threaded C++ application runnig on Solaris and need urgent clarification on the embedding architecture...
56
by: alan b | last post by:
I copied it and tried to edit the movie.htm below in the <PARAM NAME=*** location of the file where the videoclip is on my hard drive. It is already...
4
by: adsheehan | last post by:
Hi, I am embedding Python into a multi-threaded C++ application running on Solaris and need urgent clarification on the embedding architecture...
1
by: Johannes Zellner | last post by:
Hello, when embedding python: how can I create a type which simulates item getters and setters? Something like this: void setter(PyObject*...
0
by: Carl | last post by:
I have just started to look at Python's C API and the possibilities for embedding Python within another application. Where should I look for...
0
by: baitelli | last post by:
Hi where's "python24.lib" ? I'm trying to test the example given at Python documentation: 5.1 Very High Level Embedding I'm using Microsoft...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.