How kill a Thread?

What you did there was join with a timeout: threading — Thread-based parallelism — Python 3.12.1 documentation This doesn’t kill the thread; it waits for it to finish, but will only wait for that many seconds. Since the thread hadn’t finished, it returns after five seconds, but with the thread still alive.

There’s no standard way to forcibly kill a thread. Generally you need to write your own in some way. It’s a bit unfortunate (this feature would be rather handy), but it’s hard to do this reliably on all operating systems. There are some dirty hacks out there, to be sure, and they might work, but I would just make something cooperative (such as a core loop that periodically checks for an abort flag).