Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
test
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import os
|
2 |
import praw
|
|
|
|
|
3 |
from slack_sdk import WebClient
|
4 |
from slack_sdk.errors import SlackApiError
|
5 |
|
@@ -46,7 +48,7 @@ except Exception as e:
|
|
46 |
def monitor_new_posts():
|
47 |
try:
|
48 |
print("Attempting to access subreddit...")
|
49 |
-
subreddit_name = '
|
50 |
subreddit = reddit.subreddit(subreddit_name)
|
51 |
print(f"Successfully accessed subreddit: {subreddit.display_name}")
|
52 |
except Exception as e:
|
@@ -83,4 +85,16 @@ if __name__ == "__main__":
|
|
83 |
print("Starting main function...")
|
84 |
monitor_new_posts()
|
85 |
except Exception as e:
|
86 |
-
print(f"An error occurred in the main function: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import praw
|
3 |
+
from concurrent.futures import ThreadPoolExecutor
|
4 |
+
import gradio as gr
|
5 |
from slack_sdk import WebClient
|
6 |
from slack_sdk.errors import SlackApiError
|
7 |
|
|
|
48 |
def monitor_new_posts():
|
49 |
try:
|
50 |
print("Attempting to access subreddit...")
|
51 |
+
subreddit_name = 'politics' # test
|
52 |
subreddit = reddit.subreddit(subreddit_name)
|
53 |
print(f"Successfully accessed subreddit: {subreddit.display_name}")
|
54 |
except Exception as e:
|
|
|
85 |
print("Starting main function...")
|
86 |
monitor_new_posts()
|
87 |
except Exception as e:
|
88 |
+
print(f"An error occurred in the main function: {e}")
|
89 |
+
|
90 |
+
|
91 |
+
REPORT = ""
|
92 |
+
def log(msg):
|
93 |
+
global REPORT
|
94 |
+
REPORT += "\n\n" + msg
|
95 |
+
|
96 |
+
with gr.Blocks() as demo:
|
97 |
+
gr.Markdown("Background job running to check for access requests...")
|
98 |
+
report = gr.Markdown()
|
99 |
+
report.attach_load_event(lambda: REPORT, every=1)
|
100 |
+
ThreadPoolExecutor(max_workers=1).submit(monitor_new_posts)
|