From fbbc7e68444f6aa5327a3d4c444ffd1c62967aaa Mon Sep 17 00:00:00 2001 From: yellowcooln <12516003+yellowcooln@users.noreply.github.com> Date: Fri, 26 Jun 2026 09:18:41 -0400 Subject: [PATCH] fix: handle advert timeout cancellation --- repeater/web/api_endpoints.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/repeater/web/api_endpoints.py b/repeater/web/api_endpoints.py index a51ab7e..eddb78f 100644 --- a/repeater/web/api_endpoints.py +++ b/repeater/web/api_endpoints.py @@ -1580,6 +1580,7 @@ class APIEndpoints: if cherrypy.request.method == "OPTIONS": return "" + future = None try: self._require_post() if not self.send_advert_func: @@ -1588,7 +1589,6 @@ class APIEndpoints: return self._error("Event loop not available") import asyncio - future = None future = asyncio.run_coroutine_threadsafe(self.send_advert_func(), self.event_loop) result = future.result(timeout=10) return ( @@ -1601,11 +1601,8 @@ class APIEndpoints: "Error sending advert: timeout waiting for advert transmission to complete", exc_info=True, ) - try: - if future is not None: - future.cancel() - except Exception: - pass + if future is not None: + future.cancel() return self._error("Timed out waiting for advert transmission after 10 seconds") except cherrypy.HTTPError: # Re-raise HTTP errors (like 405 Method Not Allowed) without logging