μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_thread.py
Go to the documentation of this file.
1# -*- coding: utf-8 -*-
2
3import threading
4
5from pybind11_tests import thread as m
6
7
8class Thread(threading.Thread):
9 def __init__(self, fn):
10 super(Thread, self).__init__()
11 self.fn = fn
12 self.e = None
13
14 def run(self):
15 try:
16 for i in range(10):
17 self.fn(i, i)
18 except Exception as e:
19 self.e = e
20
21 def join(self):
22 super(Thread, self).join()
23 if self.e:
24 raise self.e
25
26
28 a = Thread(m.test)
29 b = Thread(m.test)
30 c = Thread(m.test)
31 for x in [a, b, c]:
32 x.start()
33 for x in [c, b, a]:
34 x.join()
35
36
38 a = Thread(m.test_no_gil)
39 b = Thread(m.test_no_gil)
40 c = Thread(m.test_no_gil)
41 for x in [a, b, c]:
42 x.start()
43 for x in [c, b, a]:
44 x.join()
def __init__(self, fn)
Definition: test_thread.py:9
def test_implicit_conversion()
Definition: test_thread.py:27
def test_implicit_conversion_no_gil()
Definition: test_thread.py:37