File tree 2 files changed +19
-12
lines changed
2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 7
7
from taskiq .compat import IS_PYDANTIC2
8
8
from taskiq .context import Context
9
9
10
- if IS_PYDANTIC2 :
11
- from pydantic import BaseModel as GenericModel
12
- else :
13
- from pydantic .generics import GenericModel # type: ignore[no-redef]
14
-
15
-
16
10
_ProgressType = TypeVar ("_ProgressType" )
17
11
18
12
@@ -25,15 +19,26 @@ class TaskState(str, enum.Enum):
25
19
RETRY = "RETRY"
26
20
27
21
28
- class TaskProgress (GenericModel , Generic [_ProgressType ]):
22
+ if IS_PYDANTIC2 :
23
+ from pydantic import BaseModel , ConfigDict
24
+
25
+ class _TaskProgressConfig (BaseModel ):
26
+ model_config = ConfigDict (arbitrary_types_allowed = True )
27
+
28
+ else :
29
+ from pydantic .generics import GenericModel
30
+
31
+ class _TaskProgressConfig (GenericModel ): # type: ignore[no-redef]
32
+ class Config :
33
+ arbitrary_types_allowed = True
34
+
35
+
36
+ class TaskProgress (_TaskProgressConfig , Generic [_ProgressType ]):
29
37
"""Progress of task execution."""
30
38
31
39
state : Union [TaskState , str ]
32
40
meta : Optional [_ProgressType ]
33
41
34
- class Config :
35
- arbitrary_types_allowed = True
36
-
37
42
38
43
class ProgressTracker (Generic [_ProgressType ]):
39
44
"""Task's dependency to set progress."""
Original file line number Diff line number Diff line change @@ -401,8 +401,10 @@ def task_cb(task: "asyncio.Task[Any]") -> None:
401
401
self .sem_prefetch .release ()
402
402
message = await queue .get ()
403
403
if message is QUEUE_DONE :
404
- logger .info ("Waiting for running tasks to complete." )
405
- await asyncio .wait (tasks , timeout = self .wait_tasks_timeout )
404
+ # asyncio.wait will throw an error if there is nothing to wait for
405
+ if tasks :
406
+ logger .info ("Waiting for running tasks to complete." )
407
+ await asyncio .wait (tasks , timeout = self .wait_tasks_timeout )
406
408
break
407
409
408
410
task = asyncio .create_task (
You can’t perform that action at this time.
0 commit comments