Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions test/test_concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,17 @@ class Simulation1 {
virtual void set_something(std::map<std::string, std::string>, std::string) {}
}; }""")

# A thread that dies with an exception only warns; collect and
# assert instead, so conversion clashes actually fail the test.
failures = []

def test():
o = {"a": "b"} # causes a temporary to be created
simulation = cppjit.gbl.CPPOverloadReuse.Simulation1()
simulation.set_something(o, ".")
try:
o = {"a": "b"} # causes a temporary to be created
simulation = cppjit.gbl.CPPOverloadReuse.Simulation1()
simulation.set_something(o, ".")
except Exception as e:
failures.append(e)

threads = [threading.Thread(target=test) for i in range(0, 100)]

Expand All @@ -264,6 +271,10 @@ def test():
for t in threads:
t.join()

assert not failures, (
f"{len(failures)} of {len(threads)} threads failed: {failures[0]}"
)

def test07_overload_reuse_in_threads_wo_gil(self):
"""Threads reuse overload objects; check for clashes if no GIL"""

Expand Down
Loading