Path: ...!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Barry Newsgroups: comp.lang.python Subject: Re: PyGILState_Ensure() deadlocks, why? Date: Sun, 7 Jul 2024 23:21:55 +0100 Lines: 25 Message-ID: References: Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de mOdNOWkutIjokxf7+jojAwxBdxQiHAvD2bQpKC9Zr8RA== Cancel-Lock: sha1:PoyIMOUWDRfMQPgKoOrSWV3aDZg= sha256:JPdgVBa+asvgGhgmyV2eeWYbboNHQTu520i/vSp24/s= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'jul': 0.04; 'thread': 0.05; 'python.': 0.08; 'cc:addr:python-list': 0.09; 'from:addr:barry': 0.09; 'received:217.70': 0.09; 'received:217.70.178': 0.09; 'received:gandi.net': 0.09; 'received:mail.gandi.net': 0.09; 'subject:skip:P 10': 0.09; 'threads': 0.09; 'cc:no real name:2**0': 0.14; 'barry': 0.16; 'c++': 0.16; 'from:addr:barrys-emacs.org': 0.16; 'init': 0.16; 'message-id:@barrys-emacs.org': 0.16; 'subject:() ': 0.16; 'url:head': 0.16; 'url:tree': 0.16; 'wrote:': 0.16; 'python': 0.16; 'cc:addr:python.org': 0.20; 'creates': 0.22; 'code': 0.23; 'cc:2**0': 0.25; 'project.': 0.27; 'email addr:python.org>': 0.28; 'think': 0.32; 'python-list': 0.32; 'but': 0.32; 'release': 0.34; 'header:In-Reply-To:1': 0.34; 'missing': 0.37; 'use': 0.39; 'wants': 0.40; 'tell': 0.60; 'research': 0.64; 'your': 0.64; 'received:217': 0.67; 'url-ip:104.18/16': 0.67; 'url:net': 0.68; 'you.': 0.71; 'near': 0.76; 'acquire': 0.84; 'email name:< ;python-list': 0.84; 'saves': 0.84; 'url:sourceforge': 0.84; 'url:p': 0.88; 'url:source': 0.89 In-Reply-To: X-Mailer: iPad Mail (21F90) X-GND-Sasl: barry@barrys-emacs.org X-Content-Filtered-By: Mailman/MimeDel 2.1.39 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Bytes: 4085 > On 7 Jul 2024, at 22:09, Tomas Ukkonen via Python-list wrote: >=20 > Py_Initialize(); You also need to tell python to init threading. I think you are missing more python setup code before you can use threads. Also i think you need to tell python that your thread wants to call into pyt= hon. But I an not near my dev system to research this for you. I have code to use python from C++ in my pysvn project. See the code starting a line 354 in https://sourceforge.net/p/pysvn/code/HEA= D/tree/trunk/pysvn/Extension/Source/pysvn.cpp That saves the thread state and restores it. But in my case python creates the threads and I release and acquire the GIL.= Barry