Skip to content

Commit 21f1a86

Browse files
Merge pull request #5 from KingWaffleIII/dev
v1.2.1
2 parents 281da8b + 575f981 commit 21f1a86

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

actions/defaults.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import os
2-
3-
import util
41
import actions
52

63
# Available actions:

main.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,19 @@ def run():
101101

102102
if __name__ == "__main__":
103103
multiprocessing.freeze_support()
104-
threading.Thread(target=run).start()
105-
util.functions.icon.run()
104+
105+
def run_with_watchdog():
106+
try:
107+
run()
108+
except asyncio.CancelledError:
109+
pass
110+
111+
run_thread = threading.Thread(target=run_with_watchdog, daemon=True)
112+
run_thread.start()
113+
114+
try:
115+
util.functions.icon.run()
116+
finally:
117+
if run_thread.is_alive():
118+
asyncio.get_event_loop().stop()
119+
run_thread.join()

util/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def take_break():
283283
),
284284
pystray.MenuItem(
285285
"Exit",
286-
lambda: os._exit(0),
286+
lambda icon: (icon.stop(), os._exit(0)),
287287
),
288288
),
289289
)

0 commit comments

Comments
 (0)