Skip to content

Commit 9bd8b7a

Browse files
committed
test: use event based init for telegram
1 parent 2a5a422 commit 9bd8b7a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/rpc/test_rpc_telegram.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ def update():
7878

7979

8080
def patch_eventloop_threading(telegrambot):
81-
is_init = False
81+
init_event = threading.Event()
8282

8383
def thread_fuck():
84-
nonlocal is_init
8584
telegrambot._loop = asyncio.new_event_loop()
86-
is_init = True
85+
init_event.set()
8786
telegrambot._loop.run_forever()
8887

8988
x = threading.Thread(target=thread_fuck, daemon=True)
9089
x.start()
91-
while not is_init:
92-
pass
90+
# Wait for thread to be properly initialized with timeout
91+
if not init_event.wait(timeout=5.0):
92+
raise RuntimeError("Failed to initialize event loop thread")
9393

9494

9595
class DummyCls(Telegram):

0 commit comments

Comments
 (0)