Multithreading - C++ - Emulate Async Behaviour in Python #4894
Unanswered
AgazzottiR
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I have to wrap an async behaviour using C++. What I am trying to do is:
- First method: Spawns a thread and keeps the handler in the class scope.
- Second method: Returns a Boolean (True if the computation running in the first method is finished).
- Third Method: Return the C++ cached results by the first method computation.
- Call the second method once in a while to see if the computation is finished.
- When Finished get the results.
All the data passing can be done through the pybind11/stl.h . I am not sharing memory among python and C++ but the python instance of the C++ class herself. My question arises since I have already run asynchronous tasks within a C++ bind function and I have never had problems( i.e if I did a cpp main and a python main the results where the same, while having C++ running threads asynchronously wrt the main I get some sync issues only when the main is Python). My question is do I have to keep debugging my code since everything should run the same? or the GIL causes me problems having the Cpp object used among multiple threads?
INHO I think having C++ and Python on the same instance with multiple threads could be an Issue.
Beta Was this translation helpful? Give feedback.
All reactions