[QUESTION] Why does `py::eval_file` not block and not return in QT?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
I connect a button to bellowing function call:
void EvalFile(const std::string& py_file) {
std::lock_guard<std::mutex> guard(g_python_mutex_);
py::eval_file(py_file, scope);// here will not block qt main thread, but also not return
}
First, click the button once, then the main thread will call this function but not step out of it. If paused, it always stops at
PyObject *result = PyRun_FileEx(f, fname_str.c_str(), start, global.ptr(), local.ptr(), closeFile);
which is a sub block of py::eval_file. The python file evaluated will open a UI, and I will not close it.
Then, click the button once again. The main thread could also step into this function.
Why does not this function block?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the py::eval_file entry point and the PyRun_FileEx call shown in the report, then reproduce the behavior from a Qt button callback with a Python file that opens a UI. Trace whether control returns only after that UI closes and document the observed interaction between the Qt main thread and Python execution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100