Skip to content

Commit

Permalink
Update bodyfetcher.py
Browse files Browse the repository at this point in the history
replace datetime.utcnow() with datetime.now(datetime.UTC)
  • Loading branch information
jeffschaller authored Nov 3, 2023
1 parent 1b410e4 commit 74a8716
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bodyfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 74a8716

Please sign in to comment.