|
36 | 36 | from ...meta import MetaAPI |
37 | 37 | from ...storage import StorageAPI |
38 | 38 | from ...subtask import Subtask, SubtaskAPI, SubtaskResult, SubtaskStatus |
39 | | -from ...task import TaskAPI |
40 | 39 | from .quota import QuotaActor |
41 | 40 | from .workerslot import BandSlotManagerActor |
42 | 41 |
|
@@ -178,6 +177,17 @@ async def _get_slot_manager_ref( |
178 | 177 | BandSlotManagerActor.gen_uid(band), address=self.address |
179 | 178 | ) |
180 | 179 |
|
| 180 | + @classmethod |
| 181 | + @alru_cache(cache_exceptions=False) |
| 182 | + async def _get_manager_ref( |
| 183 | + cls, session_id: str, supervisor_address: str |
| 184 | + ) -> mo.ActorRefType[BandSlotManagerActor]: |
| 185 | + from ..supervisor import SubtaskManagerActor |
| 186 | + |
| 187 | + return await mo.actor_ref( |
| 188 | + SubtaskManagerActor.gen_uid(session_id), address=supervisor_address |
| 189 | + ) |
| 190 | + |
181 | 191 | @alru_cache(cache_exceptions=False) |
182 | 192 | async def _get_band_quota_ref(self, band: str) -> mo.ActorRefType[QuotaActor]: |
183 | 193 | return await mo.actor_ref(QuotaActor.gen_uid(band), address=self.address) |
@@ -415,10 +425,12 @@ async def internal_run_subtask(self, subtask: Subtask, band_name: str): |
415 | 425 | # pop the subtask info at the end is to cancel the job. |
416 | 426 | self._subtask_info.pop(subtask.subtask_id, None) |
417 | 427 |
|
418 | | - task_api = await TaskAPI.create( |
| 428 | + manager_ref = await self._get_manager_ref( |
419 | 429 | subtask.session_id, subtask_info.supervisor_address |
420 | 430 | ) |
421 | | - await task_api.set_subtask_result(subtask_info.result) |
| 431 | + await manager_ref.set_subtask_result.tell( |
| 432 | + subtask_info.result, (self.address, subtask_info.band_name) |
| 433 | + ) |
422 | 434 | return subtask_info.result |
423 | 435 |
|
424 | 436 | async def _retry_run_subtask( |
@@ -557,8 +569,10 @@ async def subtask_caller(): |
557 | 569 | ) |
558 | 570 | _fill_subtask_result_with_exception(subtask, band_name, res) |
559 | 571 |
|
560 | | - task_api = await TaskAPI.create(subtask.session_id, supervisor_address) |
561 | | - await task_api.set_subtask_result(res) |
| 572 | + manager_ref = await self._get_manager_ref( |
| 573 | + subtask.session_id, supervisor_address |
| 574 | + ) |
| 575 | + await manager_ref.set_subtask_result.tell(res, (self.address, band_name)) |
562 | 576 | finally: |
563 | 577 | self._subtask_info.pop(subtask_id, None) |
564 | 578 | self._finished_subtask_count.record(1, {"band": self.address}) |
|
0 commit comments