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.
This commit is contained in:
parent
74939d2bfe
commit
1b7db6e037
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Reference in New Issue