(self, timeout: Optional[float] = None)
| 127 | ) |
| 128 | |
| 129 | async def result(self, timeout: Optional[float] = None) -> Any: |
| 130 | if not self._future: |
| 131 | raise RuntimeError("Task hasn't been started") |
| 132 | |
| 133 | loop = asyncio.get_running_loop() |
| 134 | |
| 135 | def _get_result(): |
| 136 | try: |
| 137 | result = self._future.result(timeout) # type: ignore |
| 138 | # self.kill() |
| 139 | return result |
| 140 | except TimeoutError: |
| 141 | raise TimeoutError( |
| 142 | "The task did not complete within the specified timeout." |
| 143 | ) |
| 144 | |
| 145 | return await loop.run_in_executor(None, _get_result) |
| 146 | |
| 147 | def kill(self, terminate_thread: bool = False) -> None: |
| 148 | """Kill the task and optionally terminate its thread.""" |
no outgoing calls
no test coverage detected