Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ markets = ['DOTUSDT', 'BTCUSDT', 'ADAUSDT', 'BNBUSDT', 'SUIUSDT', 'XRPUSDT']
|
|
20 |
# Initialize Hugging Face API
|
21 |
api = HfApi()
|
22 |
|
23 |
-
# πΉ Initialize loop control variable
|
24 |
loop_running = False
|
25 |
|
26 |
# Function to fetch data from CoinEx
|
@@ -72,7 +72,7 @@ def upload_to_huggingface():
|
|
72 |
|
73 |
# Function to fetch, append & update the CSV
|
74 |
def fetch_data():
|
75 |
-
global loop_running
|
76 |
while loop_running:
|
77 |
try:
|
78 |
all_data = []
|
@@ -115,8 +115,7 @@ st.title("π Live Cryptocurrency Data Fetching")
|
|
115 |
|
116 |
# Start Fetching Button
|
117 |
if st.button("Start Fetching Data"):
|
118 |
-
|
119 |
-
if not loop_running:
|
120 |
loop_running = True
|
121 |
threading.Thread(target=fetch_data, daemon=True).start()
|
122 |
st.success("β
Started fetching and saving data.")
|
|
|
20 |
# Initialize Hugging Face API
|
21 |
api = HfApi()
|
22 |
|
23 |
+
# πΉ Initialize loop control variable (Fixed Global Issue)
|
24 |
loop_running = False
|
25 |
|
26 |
# Function to fetch data from CoinEx
|
|
|
72 |
|
73 |
# Function to fetch, append & update the CSV
|
74 |
def fetch_data():
|
75 |
+
global loop_running # β
Fixed Scope Issue
|
76 |
while loop_running:
|
77 |
try:
|
78 |
all_data = []
|
|
|
115 |
|
116 |
# Start Fetching Button
|
117 |
if st.button("Start Fetching Data"):
|
118 |
+
if not loop_running: # β
Fixed issue by ensuring variable scope
|
|
|
119 |
loop_running = True
|
120 |
threading.Thread(target=fetch_data, daemon=True).start()
|
121 |
st.success("β
Started fetching and saving data.")
|