Crash with Python 3.12+ When Using Concurrent Threads
まだ誰も着手していません。
評価
調査の方向性
添付されたTestQtBoostPython312.zipから始め、1つのスレッドでPy_Initialize()を実行し、別のスレッドでBoost.Pythonの呼び出しを実行してクラッシュを再現し、Python 3.11と3.12を比較します。スレッドに関連する初期化および実行パスを調査します。原因が特定され、互換性のある動作または必要な修正が文書化されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi, I have a Windows application that has been using Boost Python for many years now, and we are looking to upgrade from Python 3.7 to Python 3.12. This is a C++ application written in Qt5 that uses Boost Python to interface with Python scripts that do some scientific calculations, and the results are displayed in the C++ application. As such, these calculations are by and large done on a concurrent thread so as not to block the UI; however, some quick python functions are run from the main thread.
The problem is that something changed in the Python 3.12 upgrade, and I'm not sure what -- but now it crashes when I run Python code from a different thread from the one I called Py_Initialize() on. I've tested up to Python 3.11, and I can Py_Initialize() on the main thread and call Python code from any thread and everything works. But starting in Python 3.12, that's no longer the case. If I initialize Python on the UI thread, I can only run it from that thread. If I initialize it on a concurrent thread, I can only run it on a concurrent thread.
Since I am using Python, Qt5, and Boost Python, I am not 100% sure where the fault lies, but I posted to the Python github and they suggested I post here as well.
I have attached a minimal example project in case that's helpful for debugging: TestQtBoostPython312.zip
Essentially, this is the meat of my code:
//Initialization Function:
Py_Initialize();
//Boost Python Code:
boost::python::object main = boost::python::import("__main__");
boost::python::object name_space(main.attr("__dict__"));
boost::python::exec_file("testPython.py", name_space, name_space);
double testNumber = boost::python::extract<double>(name_space["testNumber"]);
qDebug() << testNumber; //print(testNumber)
#testPython.py:
import random
testNumber = random.random()
Thanks for any help you can provide.
- 主要言語
- HTML
- スター
- 8.6k
- フォーク
- 2k
- 平均マージ
- 9時間 35分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/boost のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
似ている issue
-
bug mac
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
VictorKildahl/cra#694 ·
メンテナーはふだん 1 日以内に返信
-
tech-debt
難易度 2/5 半日 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
agent:WSL bug code-review gpu linux pri:medium sev:low
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
babalae/better-genshin-impact#3982 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
guts: platform guts: ui
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Open-Resin-Alliance/DragonFruit#1048 ·
メンテナーはふだん 1 日以内に返信