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
75
75
modified_task = calculate_meaning_of_life.using(priority = 10 )
76
76
```
77
77
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.
79
79
80
80
### Enqueueing tasks
81
81
Original file line number Diff line number Diff line change 17
17
18
18
from asgiref .sync import async_to_sync , sync_to_async
19
19
from django .db .models .enums import TextChoices
20
- from django .utils import timezone
21
20
from django .utils .translation import gettext_lazy as _
22
21
from typing_extensions import ParamSpec , Self
23
22
@@ -110,10 +109,7 @@ def using(
110
109
if queue_name is not None :
111
110
changes ["queue_name" ] = queue_name
112
111
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
117
113
if backend is not None :
118
114
changes ["backend" ] = backend
119
115
Original file line number Diff line number Diff line change 1
1
import dataclasses
2
- from datetime import datetime , timedelta
2
+ from datetime import datetime
3
3
4
4
from django .test import SimpleTestCase , override_settings
5
5
from django .utils import timezone
@@ -97,10 +97,6 @@ def test_using_run_after(self) -> None:
97
97
98
98
self .assertIsNone (test_tasks .noop_task .run_after )
99
99
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
- )
104
100
self .assertIsNone (test_tasks .noop_task .run_after )
105
101
106
102
def test_using_unknown_backend (self ) -> None :
You can’t perform that action at this time.
0 commit comments