developersajidbashir commited on
Commit
8739669
·
verified ·
1 Parent(s): 3fd9651

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -130,7 +130,12 @@ def run_model():
130
  except Exception as e:
131
  print(f"An error occurred: {e}")
132
  break
133
-
 
 
 
 
 
134
  if __name__ == "__main__":
135
  data = fetch_data()
136
  data = calculate_ema(data)
@@ -140,4 +145,5 @@ if __name__ == "__main__":
140
  env = DummyVecEnv([lambda: TradingEnv(data)])
141
 
142
  model = PPO.load("ppo_trading_agent", env=env)
143
- run_model()
 
 
130
  except Exception as e:
131
  print(f"An error occurred: {e}")
132
  break
133
+
134
+ def start_model_in_background():
135
+ thread = threading.Thread(target=run_model)
136
+ thread.daemon = True
137
+ thread.start()
138
+
139
  if __name__ == "__main__":
140
  data = fetch_data()
141
  data = calculate_ema(data)
 
145
  env = DummyVecEnv([lambda: TradingEnv(data)])
146
 
147
  model = PPO.load("ppo_trading_agent", env=env)
148
+ start_model_in_background()
149
+ gr.Interface(fn="Model is running in the background", inputs=[], outputs="text").launch()