[QUESTION] How to execute on other thread and stop execution by user
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Hi,
I made a simple sample that:
- Start a C++ thread
- Execute python code with pybind11 in the thread created
- Check if "stopped" variable is true and interrupt execution
Sample:
https://github.com/prsolucoes/pybind11-test/blob/master/src/cpp/main.cpp#L26-L35
The problem:
The line "py::exec(content);" block thread execution and i need that it stop run when "stopped" variable is "true".
Question:
How can i execute the python code and stop it while it is running correctly?
Thanks.
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 with the linked sample at src/cpp/main.cpp#L26-L35 and inspect how py::exec(content) runs in the created C++ thread. Research pybind11's execution and interruption behavior, including the stopped flag, then determine what a correct user-controlled stop would require.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100