prakashkota commited on
Commit
acfd5f1
ยท
1 Parent(s): c77b6e7

added code for threading lock and live in yfinance and gradio

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -27,7 +27,7 @@
27
  # This is the best Notebook Code for the NN Model
28
  #
29
  # Written on: 28 Mar 2025
30
- # Last update: 29 Mar 2025
31
  #+--------------------------------------------------------------------------------------------+
32
 
33
  import gradio as gr
@@ -50,6 +50,11 @@ from pytz import timezone
50
  from pandas.tseries.offsets import BDay
51
  import hashlib
52
 
 
 
 
 
 
53
  # --- Load saved model and scalers --- #
54
  model_dir = "./model"
55
  # import os
@@ -91,7 +96,7 @@ def predict_stock():
91
  auto_adjust=False,
92
  actions=False,
93
  progress=False,
94
- threads=False
95
  )
96
  if full_data.empty:
97
  raise RuntimeError("Download failed or returned no data.")
@@ -214,7 +219,7 @@ demo = gr.Interface(
214
  ],
215
  title="๐Ÿ“ˆ NVDA Stock Predictor",
216
  description="This app uses a Dense Neural Network to predict NVDA's next trading day's closing price.",
217
- live=False
218
  )
219
 
220
  demo.launch(share=True)
 
27
  # This is the best Notebook Code for the NN Model
28
  #
29
  # Written on: 28 Mar 2025
30
+ # Last update: 02 Apr 2025
31
  #+--------------------------------------------------------------------------------------------+
32
 
33
  import gradio as gr
 
50
  from pandas.tseries.offsets import BDay
51
  import hashlib
52
 
53
+ import threading
54
+ lock = threading.Lock()
55
+ # This forces all inference requests to run one at a time, which avoids file
56
+ # lock conflicts in SQLite. Itโ€™s simple but effective for debugging.
57
+
58
  # --- Load saved model and scalers --- #
59
  model_dir = "./model"
60
  # import os
 
96
  auto_adjust=False,
97
  actions=False,
98
  progress=False,
99
+ threads=True #<-- for parallel downloads, use True
100
  )
101
  if full_data.empty:
102
  raise RuntimeError("Download failed or returned no data.")
 
219
  ],
220
  title="๐Ÿ“ˆ NVDA Stock Predictor",
221
  description="This app uses a Dense Neural Network to predict NVDA's next trading day's closing price.",
222
+ live=True #<-- changed to True for live queuing
223
  )
224
 
225
  demo.launch(share=True)