@@ -113,39 +113,30 @@ def test_busy_timeout
113113 assert time . real *1000 >= 1000
114114 end
115115
116- def test_busy_timeout_blocks_gvl
117- db2 = SQLite3 ::Database . open ( "test.db" )
118- db2 . busy_timeout 1000
119-
120- time = Benchmark . measure do
116+ def test_busy_timeout_blocks_gvl_while_busy_handler_timeout_releases_gvl
117+ busy_timeout_db = SQLite3 ::Database . open ( "test.db" )
118+ busy_timeout_db . busy_timeout 1000
119+ busy_timeout_time = Benchmark . measure do
121120 @db . transaction ( :exclusive ) do
122121 assert_raises ( SQLite3 ::BusyException ) do
123- db2 . transaction ( :exclusive ) { }
122+ busy_timeout_db . transaction ( :exclusive ) { }
124123 end
125124 end
126125 end
126+ busy_timeout_db . close
127127
128- db2 . close
129-
130- assert_operator time . real , :>= , 2
131- assert_operator time . real , :< , 3
132- end
133-
134- def test_busy_handler_timeout_releases_gvl
135- db2 = SQLite3 ::Database . open ( "test.db" )
136- db2 . busy_handler_timeout = 1000
137-
138- time = Benchmark . measure do
128+ busy_handler_timeout_db = SQLite3 ::Database . open ( "test.db" )
129+ busy_handler_timeout_db . busy_handler_timeout = 1000
130+ busy_handler_timeout_time = Benchmark . measure do
139131 @db . transaction ( :exclusive ) do
140132 assert_raises ( SQLite3 ::BusyException ) do
141- db2 . transaction ( :exclusive ) { }
133+ busy_handler_timeout_db . transaction ( :exclusive ) { }
142134 end
143135 end
144136 end
137+ busy_handler_timeout_db . close
145138
146- db2 . close
147-
148- assert_operator time . real , :>= , 1
149- assert_operator time . real , :< , 2
139+ assert_operator busy_timeout_time . real , :> , busy_handler_timeout_time . real
140+ assert_operator busy_timeout_time . real , :> , busy_handler_timeout_time . real +1
150141 end
151142end
0 commit comments