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


Groups > comp.lang.python > #109287

Re: Manipulate GIL to have Python thread work with pthread native ones

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Terry Reedy <tjreedy@udel.edu>
Newsgroups comp.lang.python
Subject Re: Manipulate GIL to have Python thread work with pthread native ones
Date Tue, 31 May 2016 12:31:09 -0400
Lines 19
Message-ID <mailman.55.1464712287.1839.python-list@python.org> (permalink)
References <1727544946.3450439.1464671782195.JavaMail.zimbra@alumni.sjtu.edu.cn> <nike8g$2v4$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de ZDym0lXEsr+QWgg9lBZMMAY1MJ15qFNoyNLnFADRQ2bw==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'api.': 0.04; 'subject:Python': 0.05; '(actually': 0.09; 'c/c++': 0.09; 'considered.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'jan': 0.11; 'files.': 0.13; 'subject: \n ': 0.15; 'ctype': 0.16; 'pipes': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'subject:GIL': 0.16; 'wrote:': 0.16; 'implementing': 0.18; 'processor': 0.18; 'library': 0.20; 'c++,': 0.22; 'pass': 0.22; 'am,': 0.23; 'written': 0.24; 'header:In- Reply-To:1': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'module.': 0.27; 'subscriber': 0.27; "i'm": 0.30; 'code': 0.30; 'extend': 0.31; 'run': 0.33; 'options': 0.33; 'legacy': 0.33; 'c++': 0.35; 'interact': 0.35; 'subject:work': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'done.': 0.37; 'shared': 0.38; 'data': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'notified': 0.62; 'received:96': 0.63; 'subject:have': 0.80; 'received:fios.verizon.net': 0.91
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host pool-96-227-207-81.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0
In-Reply-To <1727544946.3450439.1464671782195.JavaMail.zimbra@alumni.sjtu.edu.cn>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <nike8g$2v4$1@ger.gmane.org>
X-Mailman-Original-References <1727544946.3450439.1464671782195.JavaMail.zimbra@alumni.sjtu.edu.cn>
Xref csiph.com comp.lang.python:109287

Show key headers only | View raw


On 5/31/2016 1:16 AM, qshhnkf@alumni.sjtu.edu.cn wrote:
> Hi Python experts,
>
> I need to extend Python with C/C++ to interact with an in-house
> legacy API. I'm implementing a data subscriber with Python, which
> subscribes to a data publisher (actually a ZeroMQ publisher socket)
> and will get notified once any new messages are fed. In my
> subscriber, the messages are dumped to a data processor after
> received. The subscriber will also get notified by the processor when
> done. Since the data processor is written in C++, I have to extend
> the Python code with a simple C++ module.

A couple of options you may not have considered.  A. Run the C++ module 
in a subprocess.  Pass data either in pipes or files.  B. Compile the 
C++ module to a shared library and access via ctype module.

-- 
Terry Jan Reedy

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


Thread

Re: Manipulate GIL to have Python thread work with pthread native ones Terry Reedy <tjreedy@udel.edu> - 2016-05-31 12:31 -0400

csiph-web