Crash with Python 3.12+ When Using Concurrent Threads
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con el archivo adjunto TestQtBoostPython312.zip y reproduce el fallo ejecutando Py_Initialize() en un hilo y las llamadas de Boost.Python en otro, comparando Python 3.11 y 3.12. Inspecciona la ruta de inicialización y ejecución relacionada con los hilos; el trabajo estará terminado cuando se haya identificado la causa y se haya documentado el comportamiento compatible o la corrección necesaria.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- HTML
- Estrellas
- 8.6k
- Forks
- 2k
- Merge medio
- 9 h 35 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de boostorg/boost
-
Add More GHA Runners to CIAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
-
Boost 1.92.0 build errorAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Todos los issues de boostorg/boost
Issues similares
-
bug mac
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
VictorKildahl/cra#694 ·
Los mantenedores suelen responder en 1 día
-
tech-debt
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
agent:WSL bug code-review gpu linux pri:medium sev:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
babalae/better-genshin-impact#3982 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
guts: platform guts: ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Open-Resin-Alliance/DragonFruit#1048 ·
Los mantenedores suelen responder en 1 día