From 1191506f36585fd9c1e197edbb66724f1cc8286a Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Mon, 22 Apr 2024 13:07:12 -0500 Subject: [PATCH] Add test for mt w/connect & close. Refs #2874 --- tests/db_tests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/db_tests.py b/tests/db_tests.py index 95da4b0ba..7f2fcd9be 100644 --- a/tests/db_tests.py +++ b/tests/db_tests.py @@ -387,6 +387,21 @@ def read_user_count(n): for t in threads: t.join() self.assertEqual(data.qsize(), self.nrows * self.nthreads) + def test_mt_general(self): + def connect_close(): + for _ in range(self.nrows): + self.database.connect() + with self.database.atomic() as txn: + self.database.execute_sql('select 1').fetchone() + self.database.close() + + threads = [] + for i in range(self.nthreads): + threads.append(threading.Thread(target=connect_close)) + + for t in threads: t.start() + for t in threads: t.join() + class TestDeferredDatabase(BaseTestCase): def test_deferred_database(self):