Skip to content

Commit

Permalink
allowing user to exit while running in bg
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushCodez committed Feb 7, 2022
1 parent a3dec6c commit f7b85fb
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ def change_state(*args):


def poll():
global thread_death
global thread_death, run_in_bg
while True:
with open("bg_run.txt", 'r') as f:
bg_run = int(f.read())
if thread_death and not(bg_run):
if (thread_death and not(bg_run)) or not(run_in_bg):
print("\nShutting down...")
break
# update graphs with new data
Expand All @@ -513,6 +513,7 @@ def poll():


thread_death = False
run_in_bg = True


def main():
Expand All @@ -525,9 +526,17 @@ def main():
disk_graph.animate()

def on_closing():
global thread_death
global thread_death, run_in_bg
thread_death = True
window.destroy()
with open("bg_run.txt", 'r') as f:
bg_run = int(f.read())
if bg_run == 1:
nu = input("Press enter to exit")
run_in_bg = False



window.protocol("WM_DELETE_WINDOW", on_closing)
window.mainloop()
except KeyboardInterrupt:
Expand Down

0 comments on commit f7b85fb

Please sign in to comment.