55import socket
66from uuid import uuid4
77
8- from datetime import datetime
8+ from datetime import datetime , UTC
99from itertools import repeat
1010
1111from rq .exceptions import NoSuchJobError
@@ -216,7 +216,7 @@ def enqueue_in(self, time_delta, func, *args, **kwargs):
216216 """
217217 Similar to ``enqueue_at``, but accepts a timedelta instead of datetime object.
218218 The job's scheduled execution time will be calculated by adding the timedelta
219- to datetime.utcnow( ).
219+ to datetime.now(UTC ).
220220 """
221221 timeout = kwargs .pop ('timeout' , None )
222222 job_id = kwargs .pop ('job_id' , None )
@@ -237,7 +237,7 @@ def enqueue_in(self, time_delta, func, *args, **kwargs):
237237 if at_front :
238238 job .enqueue_at_front = True
239239 self .connection .zadd (self .scheduled_jobs_key ,
240- {job .id : to_unix (datetime .utcnow ( ) + time_delta )})
240+ {job .id : to_unix (datetime .now ( UTC ) + time_delta )})
241241 return job
242242
243243 def schedule (self , scheduled_time , func , args = None , kwargs = None ,
@@ -391,7 +391,7 @@ def get_jobs_to_queue(self, with_times=False):
391391 If with_times is True a list of tuples consisting of the job instance and
392392 it's scheduled execution time is returned.
393393 """
394- return self .get_jobs (to_unix (datetime .utcnow ( )), with_times = with_times )
394+ return self .get_jobs (to_unix (datetime .now ( UTC )), with_times = with_times )
395395
396396 def get_queue_for_job (self , job ):
397397 """
@@ -431,7 +431,7 @@ def enqueue_job(self, job):
431431 if job .meta ['repeat' ] == 0 :
432432 return
433433 self .connection .zadd (self .scheduled_jobs_key ,
434- {job .id : to_unix (datetime .utcnow ( )) + int (interval )})
434+ {job .id : to_unix (datetime .now ( UTC )) + int (interval )})
435435 elif cron_string :
436436 # If this is a repeat job and counter has reached 0, don't repeat
437437 if repeat is not None :
0 commit comments