Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10646

Re: Quick question about threads and interpreters.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python.': 0.04; 'thread,': 0.04; 'pointer': 0.05; 'python': 0.08; 'ira': 0.09; 'namespace': 0.09; 'throw': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'library': 0.15; '.dll': 0.16; 'dll,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'invoking': 0.16; 'python;': 0.16; 'return.': 0.16; 'subject:threads': 0.16; 'mon,': 0.16; 'aug': 0.19; 'received:209.85.210.174': 0.19; 'received:mail- iy0-f174.google.com': 0.19; 'subject:question': 0.21; 'so.': 0.22; 'header:In-Reply-To:1': 0.22; 'code': 0.24; 'library.': 0.25; 'function': 0.26; 'do,': 0.28; 'bit': 0.28; 'message- id:@mail.gmail.com': 0.28; 'explicitly': 0.29; 'code,': 0.29; 'parent': 0.30; 'chris': 0.32; 'actually': 0.33; 'to:addr:python- list': 0.34; 'dll': 0.35; 'thread': 0.37; 'unless': 0.37; 'another': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'easiest': 0.38; 'think': 0.38; 'common': 0.39; 'easier': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'might': 0.39; 'received:209': 0.40; 'called': 0.40; 'where': 0.40; 'your': 0.60; 'back': 0.63; 'direct': 0.66; 'exact': 0.69; '100%': 0.82; 'along,': 0.84; 'code;': 0.84; 'gray': 0.84; 'from.': 0.93; 'safer': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DOH+fUxLH3MoqWT2fDebe/22sAVFeKZRT9L4Ygn456M=; b=KE6gk1ABXPUExnW8noN6D4PhAhTQDfgoFBLr/3F8T6yHrW4pIuAu3LFtpn0907dvF2 w8h4hASn6eXgXi/BENSODIRGmGaaFp47LLliGoEScBGa3Oaf04oMox+0CZ/GWDuvoQCd 5hRpy6EEF42cvFxYZwlbZnDCekTQZ6xr0WUe8=
MIME-Version 1.0
In-Reply-To <CA+QnYAVBeckEM3ebJKpH6tDp=ROyAsdHdG+-NzxTxGzZnF9kTg@mail.gmail.com>
References <CA+QnYAVBeckEM3ebJKpH6tDp=ROyAsdHdG+-NzxTxGzZnF9kTg@mail.gmail.com>
Date Mon, 1 Aug 2011 06:57:41 +0100
Subject Re: Quick question about threads and interpreters.
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1711.1312178264.1164.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312178264 news.xs4all.nl 23956 [2001:888:2000:d::a6]:60734
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10646

Show key headers only | View raw


On Mon, Aug 1, 2011 at 6:04 AM, Ira Gray <tkjthingone@gmail.com> wrote:
> I come along, write a .DLL and throw it into the program. My .dll has its
> own thread (right?),

Not unless you actually create one. A DLL is simply a puddle of code;
the application calls your code, you do whatever you do, you return.
At no time will this start another thread, unless you explicitly do
so.

I think the easiest way to do what you're talking about is to keep it
all on the same thread, and then call back into Python. Use the same
global and local dictionaries, and then the Python namespace will be
common across both your original code and the code your DLL is
invoking - which will allow you to call that "existing functionality"
you referred to.

You will have to be careful to ensure that your DLL calls into the
exact same Python library that the main application is. This might be
a bit tricky, if you're not 100% sure of where your DLL is going to be
called from. It might be easier and safer to have your parent program
actually provide a function pointer to the DLL, which the DLL can then
use to call on Python; that way, there's no direct linkage from your
DLL to the Python library.

Chris Angelico

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Quick question about threads and interpreters. Chris Angelico <rosuav@gmail.com> - 2011-08-01 06:57 +0100

csiph-web