Based on your comment on L31, you note that you created thread_conn for safety. However, L33-34 continue to use your original connection.
thread_conn
Is this merely an error? Or do you intentionally disregard the "thread safety" for which you noted?
Yep, looks like an error