Spaces:
Runtime error
Runtime error
acecalisto3
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import asyncio
|
2 |
import csv
|
3 |
import logging
|
4 |
import os
|
@@ -17,7 +16,23 @@ from sqlalchemy import create_engine, Column, Integer, String, Text, DateTime
|
|
17 |
from sqlalchemy.orm import declarative_base, sessionmaker
|
18 |
from sqlalchemy.exc import SQLAlchemyError
|
19 |
import validators
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Configure logging
|
22 |
logging.basicConfig(level=logging.INFO,
|
23 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
@@ -292,4 +307,7 @@ with gr.Blocks() as demo:
|
|
292 |
asyncio.create_task(periodic_update())
|
293 |
|
294 |
if __name__ == "__main__":
|
|
|
|
|
|
|
295 |
demo.launch()
|
|
|
|
|
1 |
import csv
|
2 |
import logging
|
3 |
import os
|
|
|
16 |
from sqlalchemy.orm import declarative_base, sessionmaker
|
17 |
from sqlalchemy.exc import SQLAlchemyError
|
18 |
import validators
|
19 |
+
import asyncio
|
20 |
|
21 |
+
# Periodic update function
|
22 |
+
async def periodic_update():
|
23 |
+
while True:
|
24 |
+
await asyncio.sleep(300) # Wait for 5 minutes
|
25 |
+
await update_feed_content()
|
26 |
+
|
27 |
+
def start_periodic_task():
|
28 |
+
loop = asyncio.get_event_loop()
|
29 |
+
if loop.is_running():
|
30 |
+
asyncio.create_task(periodic_update())
|
31 |
+
else:
|
32 |
+
loop.run_until_complete(periodic_update())
|
33 |
+
|
34 |
+
# Start the periodic update task
|
35 |
+
start_periodic_task()
|
36 |
# Configure logging
|
37 |
logging.basicConfig(level=logging.INFO,
|
38 |
format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
307 |
asyncio.create_task(periodic_update())
|
308 |
|
309 |
if __name__ == "__main__":
|
310 |
+
loop = asyncio.get_event_loop()
|
311 |
+
if not loop.is_running():
|
312 |
+
loop.run_until_complete(periodic_update())
|
313 |
demo.launch()
|