mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
test: use event based init for telegram
This commit is contained in:
@@ -78,18 +78,18 @@ def update():
|
|||||||
|
|
||||||
|
|
||||||
def patch_eventloop_threading(telegrambot):
|
def patch_eventloop_threading(telegrambot):
|
||||||
is_init = False
|
init_event = threading.Event()
|
||||||
|
|
||||||
def thread_fuck():
|
def thread_fuck():
|
||||||
nonlocal is_init
|
|
||||||
telegrambot._loop = asyncio.new_event_loop()
|
telegrambot._loop = asyncio.new_event_loop()
|
||||||
is_init = True
|
init_event.set()
|
||||||
telegrambot._loop.run_forever()
|
telegrambot._loop.run_forever()
|
||||||
|
|
||||||
x = threading.Thread(target=thread_fuck, daemon=True)
|
x = threading.Thread(target=thread_fuck, daemon=True)
|
||||||
x.start()
|
x.start()
|
||||||
while not is_init:
|
# Wait for thread to be properly initialized with timeout
|
||||||
pass
|
if not init_event.wait(timeout=5.0):
|
||||||
|
raise RuntimeError("Failed to initialize event loop thread")
|
||||||
|
|
||||||
|
|
||||||
class DummyCls(Telegram):
|
class DummyCls(Telegram):
|
||||||
|
|||||||
Reference in New Issue
Block a user