Skip to content

Commit 8e0e69a

Browse files
Merge pull request #13 from KingWaffleIII/dev
v1.2.4
2 parents b943608 + 37d53e5 commit 8e0e69a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

main.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,17 @@ def procrastination():
6767
asyncio.run(OnProcrastinationActionSet.execute())
6868

6969

70-
async def watch(break_event: multiprocessing.Event):
71-
proc = None
70+
procrastination_proc: multiprocessing.Process | None = None
71+
72+
73+
async def watch(break_event):
74+
global procrastination_proc
75+
7276
while True:
7377
if break_event.is_set():
78+
if procrastination_proc is not None and procrastination_proc.is_alive():
79+
procrastination_proc.kill()
80+
procrastination_proc = None
7481
raise asyncio.CancelledError
7582

7683
window = win32gui.GetWindowText(win32gui.GetForegroundWindow())
@@ -79,15 +86,17 @@ async def watch(break_event: multiprocessing.Event):
7986
and any(x in window.lower() for x in util.config.config["blacklist"])
8087
and not any(x in window.lower() for x in util.config.config["whitelist"])
8188
):
82-
if proc is None or not proc.is_alive():
89+
if procrastination_proc is None or not procrastination_proc.is_alive():
8390
util.functions.start_timer()
8491
util.functions.set_window(window)
85-
proc = Process(target=procrastination)
86-
proc.start()
92+
procrastination_proc = Process(
93+
target=procrastination, name="procrastination"
94+
)
95+
procrastination_proc.start()
8796
else:
88-
if proc is not None and proc.is_alive():
89-
proc.kill()
90-
proc = None
97+
if procrastination_proc is not None and procrastination_proc.is_alive():
98+
procrastination_proc.kill()
99+
procrastination_proc = None
91100

92101
await AfterProcrastinationActionSet.execute()
93102

@@ -96,7 +105,7 @@ async def watch(break_event: multiprocessing.Event):
96105
time.sleep(1)
97106

98107

99-
def run_watchdog(break_event: multiprocessing.Event):
108+
def run_watchdog(break_event):
100109
while True:
101110
if not break_event.is_set():
102111
try:

0 commit comments

Comments
 (0)