/ justapi / tests / test_asyncio.py
swadhinbiswas test: add end-to-end integration test suite with gRPC and proto stubs · 7/9/2026
43e015f
18 lines · 344 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import asyncio
import threading

_loop = asyncio.new_event_loop()

def start_loop(loop):
    asyncio.set_event_loop(loop)
    loop.run_forever()

t = threading.Thread(target=start_loop, args=(_loop,), daemon=True)
t.start()

async def my_coro():
    return 42

future = asyncio.run_coroutine_threadsafe(my_coro(), _loop)
print(future.result())