/ justapi / tests / test_dump_threads.py
swadhinbiswas test: add end-to-end integration test suite with gRPC and proto stubs · 7/9/2026
43e015f
26 lines · 596 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from justapi import JustAPIApp
import asyncio, threading, sys, traceback

app = JustAPIApp()

async def hello(req):
    await asyncio.sleep(0.01)
    return {"message": "hello"}

app.get("/", hello)

def dump_threads():
    import time
    while True:
        time.sleep(2)
        print("--- THREAD DUMP ---")
        for th in threading.enumerate():
            print(th)
            traceback.print_stack(sys._current_frames()[th.ident])
        print("-------------------")

threading.Thread(target=dump_threads, daemon=True).start()

if __name__ == "__main__":
    app.run("127.0.0.1:8080")