From 55bb18d17ee27e443b244dcd3ea2a0362fc5853a Mon Sep 17 00:00:00 2001 From: Rico Date: Wed, 8 May 2019 01:38:44 +0200 Subject: [PATCH] FIX: Long wait for shutdown When trying to quickly shutdown the program, it did not work. Now we are only sleeping two seconds instead of 60 (worst case) --- pastepwn/scraping/pastebin/pastebinscraper.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pastepwn/scraping/pastebin/pastebinscraper.py b/pastepwn/scraping/pastebin/pastebinscraper.py index c645f6c..a2dd170 100644 --- a/pastepwn/scraping/pastebin/pastebinscraper.py +++ b/pastepwn/scraping/pastebin/pastebinscraper.py @@ -165,12 +165,13 @@ def start(self, paste_queue): self.running = False break - # check if time since last - current_time = int(time.time()) - diff = current_time - self._last_scrape_time - - # if the last scraping happened less than 60 seconds ago, - # wait until the 60 seconds passed - if diff < 60: - sleep_time = 60 - diff - time.sleep(sleep_time) + while self.running: + current_time = int(time.time()) + diff = current_time - self._last_scrape_time + + if diff > 60: + break + + # if the last scraping happened less than 60 seconds ago, + # wait 2 seconds and check again + time.sleep(2)