This is my app.py main function. It does write the new file 'classifier5.pkl' as intended. It worked only one time after I inserted the socket code ('liveconsole' if-statement). I ran other tests which indicate main is not even being called when I restart/reload my website.
if __name__ == '__main__':
clf = update_model(db_path=db,
model=clf,
batch_size=10000)
pickle.dump(clf, open(os.path.join(cur_dir,
'pkl_objects', 'classifier5.pkl'), 'wb')
, protocol=4)
if 'liveconsole' not in gethostname():
app.run()