Python Forum

Full Version: Using Terminating Signal to Terminate Long Threads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I am trying to run a thread and terminate it; this method is described here. The example given shows a short job. How would I use this method to terminate long threads when the user inputs a different command? As of now, the while loop needs to complete before it registers a different command entered; therefore, if a long thread is desired, you would need to wait until the long thread completes before the thread terminates.

Thanks,
Christopher
If you use multiprocessing you call terminate() to kill a thread/process at any time and then immediately continue on. Call join() also to clean up anything that may still exist in the background https://pymotw.com/3/multiprocessing/bas...-processes See my simple example at https://python-forum.io/Thread-Parallel-...0#pid43980