File tree Expand file tree Collapse file tree 3 files changed +3
-11
lines changed
Expand file tree Collapse file tree 3 files changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ These attributes (besides `enqueue_on_commit`) can also be modified at run-time
7575modified_task = calculate_meaning_of_life.using(priority = 10 )
7676```
7777
78- In addition to the above attributes, ` run_after ` can be passed to specify a specific time the task should run. Both a timezone-aware ` datetime ` or ` timedelta ` may be passed.
78+ In addition to the above attributes, ` run_after ` can be passed to specify a specific time the task should run.
7979
8080### Enqueueing tasks
8181
Original file line number Diff line number Diff line change 1717
1818from asgiref .sync import async_to_sync , sync_to_async
1919from django .db .models .enums import TextChoices
20- from django .utils import timezone
2120from django .utils .translation import gettext_lazy as _
2221from typing_extensions import ParamSpec , Self
2322
@@ -110,10 +109,7 @@ def using(
110109 if queue_name is not None :
111110 changes ["queue_name" ] = queue_name
112111 if run_after is not None :
113- if isinstance (run_after , timedelta ):
114- changes ["run_after" ] = timezone .now () + run_after
115- else :
116- changes ["run_after" ] = run_after
112+ changes ["run_after" ] = run_after
117113 if backend is not None :
118114 changes ["backend" ] = backend
119115
Original file line number Diff line number Diff line change 11import dataclasses
2- from datetime import datetime , timedelta
2+ from datetime import datetime
33
44from django .test import SimpleTestCase , override_settings
55from django .utils import timezone
@@ -97,10 +97,6 @@ def test_using_run_after(self) -> None:
9797
9898 self .assertIsNone (test_tasks .noop_task .run_after )
9999 self .assertEqual (test_tasks .noop_task .using (run_after = now ).run_after , now )
100- self .assertIsInstance (
101- test_tasks .noop_task .using (run_after = timedelta (hours = 1 )).run_after ,
102- datetime ,
103- )
104100 self .assertIsNone (test_tasks .noop_task .run_after )
105101
106102 def test_using_unknown_backend (self ) -> None :
You can’t perform that action at this time.
0 commit comments