test_thread.py
Go to the documentation of this file.
1 from __future__ import annotations
2 
3 import sys
4 import threading
5 
6 import pytest
7 
8 from pybind11_tests import thread as m
9 
10 
11 class Thread(threading.Thread):
12  def __init__(self, fn):
13  super().__init__()
14  self.fn = fn
15  self.e = None
16 
17  def run(self):
18  try:
19  for i in range(10):
20  self.fn(i, i)
21  except Exception as e:
22  self.e = e
23 
24  def join(self):
25  super().join()
26  if self.e:
27  raise self.e
28 
29 
30 @pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads")
32  a = Thread(m.test)
33  b = Thread(m.test)
34  c = Thread(m.test)
35  for x in [a, b, c]:
36  x.start()
37  for x in [c, b, a]:
38  x.join()
39 
40 
41 @pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads")
43  a = Thread(m.test_no_gil)
44  b = Thread(m.test_no_gil)
45  c = Thread(m.test_no_gil)
46  for x in [a, b, c]:
47  x.start()
48  for x in [c, b, a]:
49  x.join()
test_thread.Thread.fn
fn
Definition: test_thread.py:14
gtsam::range
Double_ range(const Point2_ &p, const Point2_ &q)
Definition: slam/expressions.h:30
test_thread.test_implicit_conversion
def test_implicit_conversion()
Definition: test_thread.py:31
test_thread.Thread.e
e
Definition: test_thread.py:15
test_thread.Thread.run
def run(self)
Definition: test_thread.py:17
test_thread.Thread.__init__
def __init__(self, fn)
Definition: test_thread.py:12
test_thread.test_implicit_conversion_no_gil
def test_implicit_conversion_no_gil()
Definition: test_thread.py:42
test_thread.Thread.join
def join(self)
Definition: test_thread.py:24
test_thread.Thread
Definition: test_thread.py:11


gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:06:21