Set next_break to None before while loop
This commit is contained in:
parent
a30db22c3b
commit
f6cf85ce2b
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue