diff --git a/bodyfetcher.py b/bodyfetcher.py index 244190542f..3cf64e6a41 100644 --- a/bodyfetcher.py +++ b/bodyfetcher.py @@ -182,7 +182,7 @@ def add_to_queue(self, hostname, question_id, should_check_site=False, source=No # This line only works if we are using a dict in the self.queue[hostname] object, which we # should be with the previous conversion code. - self.queue[hostname][str(question_id)] = datetime.utcnow() + self.queue[hostname][str(question_id)] = datetime.now(datetime.UTC) flovis_dict = None if GlobalVars.flovis is not None: flovis_dict = {sk: list(sq.keys()) for sk, sq in self.queue.items()} @@ -379,7 +379,7 @@ def get_first_queue_item_to_process(self, thread_stats): return None self.cpu_starvation_warning_thread_launched() special_sites = [] - is_time_sensitive_time = datetime.utcnow().hour in range(4, 12) + is_time_sensitive_time = datetime.now(datetime.UTC).hour in range(4, 12) with self.queue_lock: sites_in_queue = {site: len(values) for site, values in self.queue.items()} # Get sites listed in special cases and as time_sensitive @@ -495,7 +495,7 @@ def make_api_call_for_site(self, site, new_posts, thread_stats): {'site': site, 'posts': list(new_posts.keys())}) # Add queue timing data - pop_time = datetime.utcnow() + pop_time = datetime.now(datetime.UTC) post_add_times = [(pop_time - v).total_seconds() for k, v in new_posts.items()] Tasks.do(add_queue_timing_data, site, post_add_times) @@ -570,7 +570,7 @@ def make_api_call_for_site(self, site, new_posts, thread_stats): if GlobalVars.api_backoff_time > time.time(): time.sleep(GlobalVars.api_backoff_time - time.time() + 2) try: - time_request_made = datetime.utcnow().strftime('%H:%M:%S') + time_request_made = datetime.now(datetime.UTC).strftime('%H:%M:%S') response = requests.get(url, params=params, timeout=20).json() response_timestamp = time.time() except (requests.exceptions.Timeout, requests.ConnectionError, Exception):