4 from pybind11_tests
import gil_scoped
as m
8 """Runs target in process and returns its exitcode after 10s (None if still alive).""" 9 process = multiprocessing.Process(target=target, args=args, kwargs=kwargs)
14 process.join(timeout=10)
15 return process.exitcode
17 if process.is_alive():
22 """Calls different C++ functions that come back to Python.""" 24 class ExtendedVirtClass(m.VirtClass):
25 def virtual_func(self):
28 def pure_virtual_func(self):
31 extended = ExtendedVirtClass()
32 m.test_callback_py_obj(
lambda:
None)
33 m.test_callback_std_func(
lambda:
None)
34 m.test_callback_virtual_func(extended)
35 m.test_callback_pure_virtual_func(extended)
39 """Calls different C++ functions that come back to Python, from Python threads.""" 41 for _
in range(num_threads):
42 thread = threading.Thread(target=_python_to_cpp_to_python)
46 threads.append(thread)
49 for thread
in threads:
55 """Makes sure there is no GIL deadlock when running in a thread. 57 It runs in a separate process to be able to stop and assert if it deadlocks. 64 """Makes sure there is no GIL deadlock when running in a thread multiple times in parallel. 66 It runs in a separate process to be able to stop and assert if it deadlocks. 68 assert _run_in_process(_python_to_cpp_to_python_from_threads, 8, parallel=
True) == 0
73 """Makes sure there is no GIL deadlock when running in a thread multiple times sequentially. 75 It runs in a separate process to be able to stop and assert if it deadlocks. 78 _run_in_process(_python_to_cpp_to_python_from_threads, 8, parallel=
False) == 0
84 """Makes sure there is no GIL deadlock when using processes. 86 This test is for completion, but it was never an issue. 92 """Makes sure that the GIL can be acquired by another module from a GIL-released state.""" 93 m.test_cross_module_gil()
def _run_in_process(target, args, kwargs)
def test_python_to_cpp_to_python_from_thread_multiple_parallel()
def _python_to_cpp_to_python()
def test_python_to_cpp_to_python_from_process()
def _python_to_cpp_to_python_from_threads(num_threads, parallel=False)
Double_ range(const Point2_ &p, const Point2_ &q)
def test_cross_module_gil()
def test_python_to_cpp_to_python_from_thread_multiple_sequential()
def test_python_to_cpp_to_python_from_thread()