From 9bd8b7acf51a6e0d5421be09cf92c1d840fe75a4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 3 Jul 2025 21:08:00 +0200 Subject: [PATCH] test: use event based init for telegram --- tests/rpc/test_rpc_telegram.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 4d489c415..30420b1d6 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -78,18 +78,18 @@ def update(): def patch_eventloop_threading(telegrambot): - is_init = False + init_event = threading.Event() def thread_fuck(): - nonlocal is_init telegrambot._loop = asyncio.new_event_loop() - is_init = True + init_event.set() telegrambot._loop.run_forever() x = threading.Thread(target=thread_fuck, daemon=True) x.start() - while not is_init: - pass + # Wait for thread to be properly initialized with timeout + if not init_event.wait(timeout=5.0): + raise RuntimeError("Failed to initialize event loop thread") class DummyCls(Telegram):