From 56b28f534ed2f223a5737042716dd20e58b3c8b2 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 11 Feb 2018 09:57:31 -0500 Subject: [PATCH] Should fix the double comment problem --- run.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/run.py b/run.py index 16fd0aa..61285ab 100644 --- a/run.py +++ b/run.py @@ -12,7 +12,7 @@ subreddit = reddit.subreddit("opendirectories") subs = [] -for submission in subreddit.new(limit=50): +for submission in subreddit.new(limit=3): subs.append(submission) bot = RedditBot("crawled.txt") @@ -47,11 +47,12 @@ def execute_task(submission): print(com_string) while True: try: - submission.reply(com_string) - bot.log_crawl(submission.id) + if not bot.has_crawled(submission.id): + submission.reply(com_string) + bot.log_crawl(submission.id) break except Exception as e: - print("Waiting 5 minutes: " + str(e)) + print("Waiting 10 minutes: " + str(e)) time.sleep(600) continue @@ -67,17 +68,12 @@ while len(tq.tasks) > 0: if task is not None: if not bot.has_crawled(task.submission.id): p = Process(target=execute_task, args={task.submission}) - p.daemon = True p.start() print("Started process for " + task.submission.title) else: print("Already crawled " + task.submission) -while True: - time.sleep(1) - print("Waiting..") -