Issue
In creating a python thread with name, we can do it by
t = threading.Thread(target=func,name="my_thread")
In flask, each request spawns its own thread holding the context until the process is completed. How do i assign dynamic name to these threads being created by flask?
Solution
Just found the quick and easy solution to this. Within the flask's api context somewhere you can get the current thread and rename it:
t = threading.current_thread()
t.name = "renamed_thread"
This way, i can better see in vscode debugging window the threads spawn for each API calls without inspecting them individually...
Answered By - Ritsard
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.