473,748 Members | 3,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python, dlls, and multiple instances

Is it a correct to assume that you can use multiple instances of
python altogether if each is loaded from a separate dll? For instance,
if I write a couple of dll/so libs, and each has python statically
linked in, is it safe to assume that since dlls use their own address
space then each dll would have it's own GIL, and will therefore
coexist safely within the same app? This is correct across all
platforms, yes?

I ask because I will be writing an audio plugin that uses python both
for the gui and the audio thread. The audio thread must not be
blocked, and will also be set up as a restricted execution environment
to prevent the usual dangerous calls to open, socket, etc. The python
running in the application thread may be blocked and may do whatever
it wants.

I think my understanding is correct since our current dll
implementation statically links python, and I know that the host app
(Ableton Live) also uses python for it's scripting engine. This should
be fun, since I've wanted to write a recipe for using python in an
audio plugin GUIs for a while now.

Cheers!
Jun 27 '08 #1
2 1942
Is it a correct to assume that you can use multiple instances of
python altogether if each is loaded from a separate dll? For instance,
if I write a couple of dll/so libs, and each has python statically
linked in, is it safe to assume that since dlls use their own address
space
DLLs don't use their own address space. All DLLs of a single operating
system process use the same address space.

Different DLLs do use different portions of that address space.
then each dll would have it's own GIL, and will therefore
coexist safely within the same app? This is correct across all
platforms, yes?
No; it rather depends on the way the operating system resolves symbols.
On some systems (e.g. many Unix systems), there is only a single global
symbol table for the entire process. So when a shared library is loaded,
and needs to resolve its symbols (even the ones that it also defines
itself), it may end up finding the GIL in a different copy of the Python
interpreter, so they all share the GIL (even though there would have
been space for multiple GILs).

Regards,
Martin
Jun 27 '08 #2
ahh, ok. Looks like my fundamental understanding of how dlls work was
a little messed up. Thanks!

On Sun, Jun 1, 2008 at 10:42 AM, "Martin v. Löwis" <ma****@v.loewi s.dewrote:
>Is it a correct to assume that you can use multiple instances of
python altogether if each is loaded from a separate dll? For instance,
if I write a couple of dll/so libs, and each has python statically
linked in, is it safe to assume that since dlls use their own address
space

DLLs don't use their own address space. All DLLs of a single operating
system process use the same address space.

Different DLLs do use different portions of that address space.
>then each dll would have it's own GIL, and will therefore
coexist safely within the same app? This is correct across all
platforms, yes?

No; it rather depends on the way the operating system resolves symbols.
On some systems (e.g. many Unix systems), there is only a single global
symbol table for the entire process. So when a shared library is loaded,
and needs to resolve its symbols (even the ones that it also defines
itself), it may end up finding the GIL in a different copy of the Python
interpreter, so they all share the GIL (even though there would have
been space for multiple GILs).

Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
Jun 27 '08 #3

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

Similar topics

3
3779
by: Matthias Baas | last post by:
Hi, are there any guidelines about what to do if a Windows extension for Python 2.4 requires the C++ runtime (msvcp71.dll)? If I want to distribute a binary installer of an extension that contains C++ code, should I really include the msvcp71.dll in the package? It doesn't sound like a good idea to me if every package places another copy of this dll somewhere in the Python directory. Python 2.4 does install the C runtime (msvcr71.dll)...
10
3690
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. Andrew dalke@dalkescientific.com
8
5266
by: Rahul | last post by:
Hi. I am part of a group in my univ where we organize a programming contest. In this contest we have a UDP based server. The server simulates a game and each contestant is to develop a team of virtual players. Each team is composed of 75 similar bots...i.e. governed by the same logic. Thus the contestant submits a single copy of the client and we instantiate the same program 75 times at the same time. The problem is that while executables...
5
2069
by: Rich | last post by:
Hi there, For a quite big application, I need to get large amount of data within a static library (xxx.lib) and put them in a database (a class, say we call it CData), and then make it accessible by a few different dynamic library files (yyy.dll, …). I’ve tried to create a global class object of CData*, say pData, by declaring it as an external in the header and initiate it in the cpp of a dll file. But it doesn’t work. Other dlls...
8
2427
by: Brennus | last post by:
I have a dll/so which embeds python. I can verify it works by compiling it as an executable and adding an appropriate main. I tried to write unit tests for this library with ctypes and a simple python script. Access violations and other strange things result. I suspect this is because I am basically embedding python in python at this point. How can I make my dll/so with embedded python support use via ctypes?
113
5300
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside the Python world, you're fine. But once you do, things go downhill. MySQLdb has version and platform compatibility problems. So does M2Crypto. The built-in SSL support is weak. Even basic sockets don't quite work right; the socket module...
3
9178
by: Marcin Kalicinski | last post by:
How do I use multiple Python interpreters within the same process? I know there's a function Py_NewInterpreter. However, how do I use functions like Py_RunString etc. with it? They don't take any arguments that would tell on which interpreter to run the string...? Marcin
3
1274
by: marco Starglider | last post by:
hi, i have a very large project in visual studio2005->visual c++ in windowsxp. i'd like to port it, or my next project, over to python. is this possible without rewriting all my code? are there multiple options to do this? my project is so large, that entirely rewriting it is actually no option. regards,
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.