Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无论何时使用导入,PyRun_SimpleString都会阻塞,永远不会返回 std::cout_Python_C++_Cpython - Fatal编程技术网

Python 无论何时使用导入,PyRun_SimpleString都会阻塞,永远不会返回 std::cout

Python 无论何时使用导入,PyRun_SimpleString都会阻塞,永远不会返回 std::cout,python,c++,cpython,Python,C++,Cpython,修复了它,尝试使用PyImport\u ImportModuleNoBlock导入,它报告模块锁被另一个线程Python 2.7持有,需要使用调试器。 std::cout << "im in here!\n"; PyGILState_STATE sMain = PyGILState_Ensure(); if (sMain) { std::cout << "attempting\n"; PyRun_SimpleString("import sys; sys

修复了它,尝试使用PyImport\u ImportModuleNoBlock导入,它报告模块锁被另一个线程Python 2.7持有,需要使用调试器。
std::cout << "im in here!\n";
PyGILState_STATE sMain = PyGILState_Ensure();

if (sMain)
{
    std::cout << "attempting\n";
    PyRun_SimpleString("import sys; sys.exit();");
    std::cout << "attempted!\n";
}

PyGILState_Release(sMain);