From 1b7db6e037fe76476a952879a34a44dae7b3ad87 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Tue, 28 Jul 2026 11:06:48 -0700 Subject: [PATCH] fix(photon): guard inbound-task cancel against self-cancellation in disconnect() Follow-up widening of the #73170 pattern: apply the same asyncio.current_task() guard used for the health task (and now the supervisor task in _stop_sidecar) to the inbound-task cancel path in disconnect(), so an inbound task that triggers disconnect() cannot cancel-and-await itself. --- plugins/platforms/photon/adapter.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/platforms/photon/adapter.py b/plugins/platforms/photon/adapter.py index 8b02f58f45edd..27aa026a3b7ac 100644 --- a/plugins/platforms/photon/adapter.py +++ b/plugins/platforms/photon/adapter.py @@ -637,14 +637,16 @@ class PhotonAdapter(BasePlatformAdapter): except Exception: pass if self._inbound_task is not None: - self._inbound_task.cancel() - try: - await self._inbound_task - except asyncio.CancelledError: - pass - except Exception: - pass + task = self._inbound_task self._inbound_task = None + task.cancel() + if task is not asyncio.current_task(): + try: + await task + except asyncio.CancelledError: + pass + except Exception: + pass # Cancel any pending U+FFFC placeholder tasks. for chat_key, (_, fffc_task) in list(self._pending_fffc.items()): if fffc_task and not fffc_task.done():