Start the background worker as an asyncio.Task.
(self)
| 333 | logger.error("Error in message consumption loop: %s", e, exc_info=True) |
| 334 | |
| 335 | async def start(self) -> None: |
| 336 | """Start the background worker as an asyncio.Task.""" |
| 337 | if self._running: |
| 338 | logger.warning("Queue worker already running") |
| 339 | return |
| 340 | |
| 341 | partition_info = f" (partition {self._partition_id})" if self._partition_id is not None else "" |
| 342 | logger.info("Starting queue worker task%s...", partition_info) |
| 343 | self._running = True |
| 344 | |
| 345 | task_name = f"QueueWorker-{self._partition_id}" if self._partition_id is not None else "QueueWorker" |
| 346 | self._task = asyncio.create_task(self._consume_loop(), name=task_name) |
| 347 | |
| 348 | logger.info("Queue worker task%s started successfully", partition_info) |
| 349 | |
| 350 | async def stop(self, close_queue: bool = True) -> None: |
| 351 | """ |