MCPcopy
hub / github.com/benoitc/gunicorn / execute_async

Method execute_async

gunicorn/dirty/client.py:223–277  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 13

send_emailFunction · 0.80
email_statsFunction · 0.80
resize_imageFunction · 0.80
generate_thumbnailFunction · 0.80
image_statsFunction · 0.80
aggregate_dataFunction · 0.80
cached_queryFunction · 0.80
data_statsFunction · 0.80
run_cleanupFunction · 0.80
run_daily_reportFunction · 0.80
run_syncFunction · 0.80
scheduled_statsFunction · 0.80

Calls 8

connect_asyncMethod · 0.95
_handle_responseMethod · 0.95
_close_asyncMethod · 0.95
DirtyTimeoutErrorClass · 0.85
make_requestFunction · 0.70
write_message_asyncMethod · 0.45
read_message_asyncMethod · 0.45

Tested by

no test coverage detected