|
58 | 58 | from pydantic.networks import AnyUrl |
59 | 59 | from servicelib.logging_errors import create_troubleshootting_log_kwargs |
60 | 60 | from servicelib.logging_utils import log_context |
| 61 | +from servicelib.utils import limited_gather |
61 | 62 | from settings_library.s3 import S3Settings |
62 | 63 | from simcore_sdk.node_ports_common.exceptions import NodeportsException |
63 | 64 | from simcore_sdk.node_ports_v2 import FileLinkType |
|
92 | 93 |
|
93 | 94 |
|
94 | 95 | _UserCallbackInSepThread = Callable[[], None] |
| 96 | +_MAX_CONCURRENT_CLIENT_CONNECTIONS: Final[int] = 10 |
95 | 97 |
|
96 | 98 |
|
97 | 99 | @dataclass(frozen=True, kw_only=True, slots=True) |
@@ -423,7 +425,11 @@ async def _get_task_progress(job_id: str) -> TaskProgressEvent | None: |
423 | 425 | # we are interested in the last event |
424 | 426 | return TaskProgressEvent.model_validate_json(dask_events[-1][1]) |
425 | 427 |
|
426 | | - return await asyncio.gather(*(_get_task_progress(job_id) for job_id in job_ids)) |
| 428 | + return await limited_gather( |
| 429 | + *(_get_task_progress(job_id) for job_id in job_ids), |
| 430 | + log=_logger, |
| 431 | + limit=_MAX_CONCURRENT_CLIENT_CONNECTIONS, |
| 432 | + ) |
427 | 433 |
|
428 | 434 | async def get_tasks_status(self, job_ids: Iterable[str]) -> list[RunningState]: |
429 | 435 | dask_utils.check_scheduler_is_still_the_same( |
@@ -501,7 +507,11 @@ async def _get_task_state(job_id: str) -> RunningState: |
501 | 507 |
|
502 | 508 | return parsed_event.state |
503 | 509 |
|
504 | | - return await asyncio.gather(*(_get_task_state(job_id) for job_id in job_ids)) |
| 510 | + return await limited_gather( |
| 511 | + *(_get_task_state(job_id) for job_id in job_ids), |
| 512 | + log=_logger, |
| 513 | + limit=_MAX_CONCURRENT_CLIENT_CONNECTIONS, |
| 514 | + ) |
505 | 515 |
|
506 | 516 | async def abort_computation_task(self, job_id: str) -> None: |
507 | 517 | # Dask future may be cancelled, but only a future that was not already taken by |
|
0 commit comments