()
| 1690 | ) |
| 1691 | |
| 1692 | async def process_messages(): |
| 1693 | try: |
| 1694 | while True: |
| 1695 | data = await websocket.receive_text() |
| 1696 | # Validate and send the received message to the live queue. |
| 1697 | live_request_queue.send(LiveRequest.model_validate_json(data)) |
| 1698 | except ValidationError as ve: |
| 1699 | logger.error("Validation error in process_messages: %s", ve) |
| 1700 | |
| 1701 | # Run both tasks concurrently and cancel all if one fails. |
| 1702 | tasks = [ |