Execute an action on a dirty app (async/non-blocking). Args: app_path: Import path of the dirty app action: Action to call on the app *args: Positional arguments **kwargs: Keyword arguments Returns: Result from th
(self, app_path, action, *args, **kwargs)
| 221 | ) from e |
| 222 | |
| 223 | async def execute_async(self, app_path, action, *args, **kwargs): |
| 224 | """ |
| 225 | Execute an action on a dirty app (async/non-blocking). |
| 226 | |
| 227 | Args: |
| 228 | app_path: Import path of the dirty app |
| 229 | action: Action to call on the app |
| 230 | *args: Positional arguments |
| 231 | **kwargs: Keyword arguments |
| 232 | |
| 233 | Returns: |
| 234 | Result from the dirty app action |
| 235 | |
| 236 | Raises: |
| 237 | DirtyConnectionError: If connection fails |
| 238 | DirtyTimeoutError: If operation times out |
| 239 | DirtyError: If execution fails |
| 240 | """ |
| 241 | # Ensure connected |
| 242 | if self._writer is None: |
| 243 | await self.connect_async() |
| 244 | |
| 245 | # Build request |
| 246 | request_id = str(uuid.uuid4()) |
| 247 | request = make_request( |
| 248 | request_id=request_id, |
| 249 | app_path=app_path, |
| 250 | action=action, |
| 251 | args=args, |
| 252 | kwargs=kwargs |
| 253 | ) |
| 254 | |
| 255 | try: |
| 256 | # Send request |
| 257 | await DirtyProtocol.write_message_async(self._writer, request) |
| 258 | |
| 259 | # Receive response with timeout |
| 260 | response = await asyncio.wait_for( |
| 261 | DirtyProtocol.read_message_async(self._reader), |
| 262 | timeout=self.timeout |
| 263 | ) |
| 264 | |
| 265 | # Handle response |
| 266 | return self._handle_response(response) |
| 267 | except asyncio.TimeoutError: |
| 268 | await self._close_async() |
| 269 | raise DirtyTimeoutError( |
| 270 | "Timeout waiting for dirty app response", |
| 271 | timeout=self.timeout |
| 272 | ) |
| 273 | except Exception as e: |
| 274 | await self._close_async() |
| 275 | if isinstance(e, DirtyError): |
| 276 | raise |
| 277 | raise DirtyConnectionError(f"Communication error: {e}") from e |
| 278 | |
| 279 | def stream_async(self, app_path, action, *args, **kwargs): |
| 280 | """ |
no test coverage detected