473,387 Members | 1,925 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,387 software developers and data experts.

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 1925
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.loewis.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
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...
10
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. ...
8
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...
5
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...
8
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...
113
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...
3
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.