Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fetch csv data async (had some heartbeat blocked issues for a bit of time)
Browse files
app.py
CHANGED
@@ -56,9 +56,28 @@ async def give_verified_roles():
|
|
56 |
while True:
|
57 |
try:
|
58 |
global_df = pd.DataFrame()
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
guild = bot.get_guild(879548962464493619)
|
63 |
role = guild.get_role(900063512829755413)
|
64 |
|
|
|
56 |
while True:
|
57 |
try:
|
58 |
global_df = pd.DataFrame()
|
59 |
+
|
60 |
+
async with aiohttp.ClientSession() as session:
|
61 |
+
try:
|
62 |
+
async with session.get(
|
63 |
+
"https://docs.google.com/spreadsheets/d/1C8aLqgCqLYcMiIFf-P_Aosaa03C_WLIB_UyqvjSdWg8/export?format=csv&gid=0",
|
64 |
+
timeout=10
|
65 |
+
) as response:
|
66 |
+
if response.status != 200:
|
67 |
+
print(f"Failed to fetch CSV: HTTP {response.status}")
|
68 |
+
await asyncio.sleep(60)
|
69 |
+
continue
|
70 |
+
csv_data = await response.text()
|
71 |
+
global_df = pd.read_csv(pd.compat.StringIO(csv_data))
|
72 |
+
except asyncio.TimeoutError:
|
73 |
+
print("CSV fetch timed out.")
|
74 |
+
await asyncio.sleep(60)
|
75 |
+
continue
|
76 |
+
except Exception as e:
|
77 |
+
print(f"Error fetching CSV: {e}")
|
78 |
+
await asyncio.sleep(60)
|
79 |
+
continue
|
80 |
+
|
81 |
guild = bot.get_guild(879548962464493619)
|
82 |
role = guild.get_role(900063512829755413)
|
83 |
|