MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_bind_shared_instance

Function test_bind_shared_instance

tests/test_thread.py:54–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52
53@pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads")
54def test_bind_shared_instance():
55 nb_threads = 4
56 b = threading.Barrier(nb_threads)
57
58 def access_shared_instance():
59 b.wait()
60 for _ in range(1000):
61 m.EmptyStruct.SharedInstance # noqa: B018
62
63 threads = [
64 threading.Thread(target=access_shared_instance) for _ in range(nb_threads)
65 ]
66 for thread in threads:
67 thread.start()
68 for thread in threads:
69 thread.join()
70
71
72@pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads")

Callers

nothing calls this directly

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected