Improve exception handling
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user