Set next_break to None before while loop

This commit is contained in:
Chris Coutinho 2020-10-02 20:48:31 +02:00
parent a30db22c3b
commit f6cf85ce2b
No known key found for this signature in database
GPG Key ID: 39D360C64978F903
1 changed files with 9 additions and 13 deletions

View File

@ -135,6 +135,8 @@ def __start_idle_monitor():
"""
global smart_pause_activated
global idle_start_time
next_break = None
while __is_active():
# Wait for waiting_time seconds
idle_condition.acquire()
@ -159,19 +161,13 @@ def __start_idle_monitor():
# User is idle for break duration and wants to consider it as a break
enable_safe_eyes()
elif idle_seconds < break_interval:
try:
# Credit back the idle time
if next_break is not None:
# This method runs in a thread since the start.
# It may run before next_break is initialized in the update_next_break method
next_break = next_break_time + idle_period
enable_safe_eyes(next_break.timestamp())
else:
enable_safe_eyes()
except (NameError,UnboundLocalError):
# If next_break is not defined the above code block
# will fail with either a NameError or an UnboundLocalError
# Credit back the idle time
if next_break is not None:
# This method runs in a thread since the start.
# It may run before next_break is initialized in the update_next_break method
next_break = next_break_time + idle_period
enable_safe_eyes(next_break.timestamp())
else:
enable_safe_eyes()
else:
# User is idle for more than the time between two breaks