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

Method stream_async

gunicorn/dirty/client.py:279–305  ·  view source on GitHub ↗

Stream results from a dirty app action (async). This method returns an async iterator that yields chunks from a streaming response. Use this for actions that return generators. Args: app_path: Import path of the dirty app (e.g., 'myapp.ml:MLApp')

(self, app_path, action, *args, **kwargs)

Source from the content-addressed store, hash-verified

277 raise DirtyConnectionError(f"Communication error: {e}") from e
278
279 def stream_async(self, app_path, action, *args, **kwargs):
280 """
281 Stream results from a dirty app action (async).
282
283 This method returns an async iterator that yields chunks from a
284 streaming response. Use this for actions that return generators.
285
286 Args:
287 app_path: Import path of the dirty app (e.g., 'myapp.ml:MLApp')
288 action: Action to call on the app
289 *args: Positional arguments
290 **kwargs: Keyword arguments
291
292 Yields:
293 Chunks of data from the streaming response
294
295 Raises:
296 DirtyConnectionError: If connection fails
297 DirtyTimeoutError: If operation times out
298 DirtyError: If execution fails
299
300 Example::
301
302 async for chunk in client.stream_async("myapp.llm:LLMApp", "generate", prompt):
303 await response.write(chunk)
304 """
305 return DirtyAsyncStreamIterator(self, app_path, action, args, kwargs)
306
307 async def _close_async(self):
308 """Close the async connection."""

Calls 1