aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/tests/test_thread.py
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2022-09-14 09:28:47 +0200
committergatecat <gatecat@ds0.me>2022-09-14 09:28:47 +0200
commita72f898ff4c4237424c468044a6db9d6953b541e (patch)
tree1c4a543f661dd1b281aecf4660388491702fa8d8 /3rdparty/pybind11/tests/test_thread.py
parentf1349e114f3a16ccd002e8513339e18f5be4d31b (diff)
downloadnextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.tar.gz
nextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.tar.bz2
nextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.zip
3rdparty: Bump vendored pybind11 version for py3.11 support
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to '3rdparty/pybind11/tests/test_thread.py')
-rw-r--r--3rdparty/pybind11/tests/test_thread.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/3rdparty/pybind11/tests/test_thread.py b/3rdparty/pybind11/tests/test_thread.py
new file mode 100644
index 00000000..e89991f9
--- /dev/null
+++ b/3rdparty/pybind11/tests/test_thread.py
@@ -0,0 +1,42 @@
+import threading
+
+from pybind11_tests import thread as m
+
+
+class Thread(threading.Thread):
+ def __init__(self, fn):
+ super().__init__()
+ self.fn = fn
+ self.e = None
+
+ def run(self):
+ try:
+ for i in range(10):
+ self.fn(i, i)
+ except Exception as e:
+ self.e = e
+
+ def join(self):
+ super().join()
+ if self.e:
+ raise self.e
+
+
+def test_implicit_conversion():
+ a = Thread(m.test)
+ b = Thread(m.test)
+ c = Thread(m.test)
+ for x in [a, b, c]:
+ x.start()
+ for x in [c, b, a]:
+ x.join()
+
+
+def test_implicit_conversion_no_gil():
+ a = Thread(m.test_no_gil)
+ b = Thread(m.test_no_gil)
+ c = Thread(m.test_no_gil)
+ for x in [a, b, c]:
+ x.start()
+ for x in [c, b, a]:
+ x.join()