Spaces:
Sleeping
Sleeping
Commit
·
c6e0981
1
Parent(s):
bf15aa4
asyncio fix
Browse files
app.py
CHANGED
|
@@ -85,18 +85,22 @@ async def listen_to_alerts(r):
|
|
| 85 |
for entry_id, entry_data in new_entries:
|
| 86 |
description, entry_dict = await create_textual_description(entry_data)
|
| 87 |
await save({"content": description, "metadata": entry_dict})
|
| 88 |
-
st.toast(description, icon='🔔')
|
| 89 |
# Update the last ID read
|
| 90 |
last_id = entry_id
|
|
|
|
| 91 |
except KeyboardInterrupt:
|
| 92 |
print("Exiting...")
|
| 93 |
|
| 94 |
# Start Redis listener in a separate thread
|
| 95 |
def start_redis_listener():
|
| 96 |
try:
|
| 97 |
-
asyncio.
|
|
|
|
|
|
|
| 98 |
except Exception as e:
|
| 99 |
print(f"Error in Redis listener: {e}")
|
|
|
|
|
|
|
| 100 |
|
| 101 |
# Streamlit Application
|
| 102 |
st.set_page_config(
|
|
|
|
| 85 |
for entry_id, entry_data in new_entries:
|
| 86 |
description, entry_dict = await create_textual_description(entry_data)
|
| 87 |
await save({"content": description, "metadata": entry_dict})
|
|
|
|
| 88 |
# Update the last ID read
|
| 89 |
last_id = entry_id
|
| 90 |
+
st.toast(description, icon='🔔')
|
| 91 |
except KeyboardInterrupt:
|
| 92 |
print("Exiting...")
|
| 93 |
|
| 94 |
# Start Redis listener in a separate thread
|
| 95 |
def start_redis_listener():
|
| 96 |
try:
|
| 97 |
+
loop = asyncio.new_event_loop()
|
| 98 |
+
asyncio.set_event_loop(loop)
|
| 99 |
+
loop.run_until_complete(listen_to_alerts(r))
|
| 100 |
except Exception as e:
|
| 101 |
print(f"Error in Redis listener: {e}")
|
| 102 |
+
finally:
|
| 103 |
+
loop.close()
|
| 104 |
|
| 105 |
# Streamlit Application
|
| 106 |
st.set_page_config(
|