From a28c65febf6ad593e2362dad303fbdb646598106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Wed, 1 Jan 2025 14:18:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/analytics.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xiaomusic/analytics.py b/xiaomusic/analytics.py index 0f068d8..8080677 100644 --- a/xiaomusic/analytics.py +++ b/xiaomusic/analytics.py @@ -57,11 +57,10 @@ class Analytics: await self._send(event) async def _send(self, event): - await self.post_to_umami(event) - events = [event] - await self.run_with_cancel(self._google_send, events) + asyncio.create_task(self.post_to_umami(event)) + await self.run_with_cancel(self._google_send, [event]) - async def _google_send(self, events): + def _google_send(self, events): try: self.gtag.send(events) except Exception as e: @@ -69,7 +68,7 @@ class Analytics: async def run_with_cancel(self, func, *args, **kwargs): try: - asyncio.ensure_future(asyncio.to_thread(func, *args, **kwargs)) + asyncio.create_task(asyncio.to_thread(func, *args, **kwargs)) self.log.info("analytics run_with_cancel success") except Exception as e: self.log.warning(f"analytics run_with_cancel failed {e}") @@ -96,6 +95,7 @@ class Analytics: "type": "event", } + self.log.info(f"umami data: {data}") async with aiohttp.ClientSession() as session: headers = { "User-Agent": user_agent,