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():