File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -529,11 +529,12 @@ def reset(self):
529
529
Also restarts the timer thread if it has existed
530
530
'''
531
531
with self .timer_thread_lock :
532
+ if self .canceled or not self .thread_checking_time .is_alive ():
533
+ self .thread_checking_time = threading .Thread (target = self ._check_timer_loop )
534
+ self .thread_checking_time .start ()
535
+
532
536
self .start_time = time .time ()
533
537
self .canceled = False
534
- if not self .thread_checking_time .is_alive ():
535
- self .thread_checking_time = threading .Thread (target = self ._check_timer_loop )
536
- self .thread_checking_time .start ()
537
538
538
539
def stop (self ):
539
540
'''
@@ -556,7 +557,8 @@ def _check_timer_loop(self):
556
557
elapsed_time = time .time () - self .start_time
557
558
if elapsed_time > self .timeout_duration :
558
559
self .handler (* self .handler_args , ** self .handler_kwargs )
559
- self .canceled = True
560
+ with self .timer_thread_lock :
561
+ self .canceled = True
560
562
break
561
563
else :
562
564
time .sleep (self .timeout_duration - elapsed_time )
You can’t perform that action at this time.
0 commit comments