()
| 155 | With dirty arbiters, progress is streamed in real-time! |
| 156 | """ |
| 157 | async def generate(): |
| 158 | try: |
| 159 | client = await get_dirty_client_async() |
| 160 | async for progress in client.stream_async( |
| 161 | EMAIL_WORKER, |
| 162 | "send_bulk_emails", |
| 163 | recipients=data.recipients, |
| 164 | subject=data.subject, |
| 165 | body=data.body, |
| 166 | ): |
| 167 | yield f"data: {json.dumps(progress)}\n\n" |
| 168 | except DirtyError as e: |
| 169 | yield f"data: {json.dumps({'error': str(e)})}\n\n" |
| 170 | |
| 171 | return StreamingResponse( |
| 172 | generate(), |
no test coverage detected