Skip to content

Commit 4386a7a

Browse files
committed
fix:get_many return nones #285
1 parent b0d4861 commit 4386a7a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

scheduler/admin/task_admin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def job_execution_of(job: JobModel, task: Task) -> bool:
2020

2121
def get_job_executions_for_task(queue_name: str, scheduled_task: Task) -> List[JobModel]:
2222
queue = get_queue(queue_name)
23-
job_list: List[JobModel] = JobModel.get_many(queue.get_all_job_names(), connection=queue.connection)
23+
job_list: List[JobModel] = list(
24+
filter(lambda job: job is not None, JobModel.get_many(queue.get_all_job_names(), connection=queue.connection))
25+
)
26+
2427
res = sorted(
2528
list(filter(lambda j: job_execution_of(j, scheduled_task), job_list)), key=lambda j: j.created_at, reverse=True
2629
)

scheduler/redis_models/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def get(cls, name: str, connection: ConnectionType) -> Optional[Self]:
170170
return None
171171

172172
@classmethod
173-
def get_many(cls, names: Sequence[str], connection: ConnectionType) -> List[Self]:
173+
def get_many(cls, names: Sequence[str], connection: ConnectionType) -> List[Optional[Self]]:
174174
pipeline = connection.pipeline()
175175
for name in names:
176176
pipeline.hgetall(cls._element_key_template.format(name))

0 commit comments

Comments
 (0)