Improve exception handling

This commit is contained in:
2020-09-08 19:52:50 -06:00
parent a76d02d53c
commit e444cf6677
3 changed files with 21 additions and 8 deletions
+12 -3
View File
@@ -1,6 +1,7 @@
import importlib
import threading
import time
import traceback
from flask import Flask
app = Flask(__name__)
@@ -15,6 +16,7 @@ global_state = Bunch()
g = global_state
g.local_state = False
g.connection = False
g.mcdata = False
g.pos = False
@app.route('/')
@@ -42,9 +44,16 @@ def main():
try:
while True:
g.running = True
bot.bot(global_state)
importlib.reload(bot)
try:
g.running = True
bot.bot(global_state)
importlib.reload(bot)
except BaseException as e:
g.running = True
traceback.print_exc()
print('Locking...')
while g.running:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()