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

Function process_image_batch

examples/celery_alternative/app.py:235–258  ·  view source on GitHub ↗

Process multiple images with progress streaming.

(data: ImageBatchRequest)

Source from the content-addressed store, hash-verified

233
234@app.post("/api/image/process-batch")
235async def process_image_batch(data: ImageBatchRequest):
236 """
237 Process multiple images with progress streaming.
238 """
239 async def generate():
240 try:
241 client = await get_dirty_client_async()
242 async for progress in client.stream_async(
243 IMAGE_WORKER,
244 "process_batch",
245 images=data.images,
246 operation=data.operation,
247 width=data.width,
248 height=data.height,
249 size=data.size,
250 ):
251 yield f"data: {json.dumps(progress)}\n\n"
252 except DirtyError as e:
253 yield f"data: {json.dumps({'error': str(e)})}\n\n"
254
255 return StreamingResponse(
256 generate(),
257 media_type="text/event-stream",
258 )
259
260
261@app.get("/api/image/stats")

Callers

nothing calls this directly

Calls 1

generateFunction · 0.70

Tested by

no test coverage detected