File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,33 @@ def task():
235
235
with self .assertRaisesRegex (RuntimeError , "Cannot join current thread" ):
236
236
raise errors [0 ]
237
237
238
+ def test_detach_from_self (self ):
239
+ errors = []
240
+ start_new_thread_returned = thread .allocate_lock ()
241
+ start_new_thread_returned .acquire ()
242
+ thread_detached = thread .allocate_lock ()
243
+ thread_detached .acquire ()
244
+
245
+ def task ():
246
+ ident = thread .get_ident ()
247
+ start_new_thread_returned .acquire ()
248
+ try :
249
+ thread .detach_thread (ident )
250
+ except Exception as e :
251
+ errors .append (e )
252
+ finally :
253
+ thread_detached .release ()
254
+
255
+ with threading_helper .wait_threads_exit ():
256
+ joinable = True
257
+ ident = thread .start_new_thread (task , (), {}, joinable )
258
+ start_new_thread_returned .release ()
259
+ thread_detached .acquire ()
260
+ with self .assertRaisesRegex (ValueError , "not joinable" ):
261
+ thread .join_thread (ident )
262
+
263
+ assert len (errors ) == 0
264
+
238
265
def test_detach_then_join (self ):
239
266
lock = thread .allocate_lock ()
240
267
lock .acquire ()
You can’t perform that action at this time.
0 commit comments