Python Forum
Using Terminating Signal to Terminate Long Threads
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Terminating Signal to Terminate Long Threads
#1
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
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  The game should now run and terminate once the board is full, but still can’t identif rango 0 1,454 Jul-22-2021, 03:24 AM
Last Post: rango
  Terminating Subprocesses and Threads while they're calculating lvlanson 4 2,510 Oct-17-2020, 12:33 PM
Last Post: lvlanson
Question Terminating threads Gilush 1 1,881 Jun-09-2020, 09:57 AM
Last Post: Gribouillis
  Is there a way to not terminate a running thread in python Contra_Boy 3 1,974 May-05-2020, 09:38 PM
Last Post: SheeppOSU
  Terminate a process when hotkey is pressed 66Gramms 0 2,241 Dec-24-2019, 06:41 PM
Last Post: 66Gramms
  How to terminate the caller fuction through callee? 100k 2 2,144 Nov-27-2019, 06:49 PM
Last Post: jefsummers
  How to terminate a list of inputs with a set value? SOS Manning 2 2,181 Sep-19-2019, 01:54 AM
Last Post: scidam
  how to terminate all the processes in C py2exe 0 2,070 Aug-02-2018, 04:31 AM
Last Post: py2exe
  lambda-Amazon EC2:Remove instance termination protection if enabled and terminate ins dragan979 0 3,352 Jun-13-2018, 09:48 AM
Last Post: dragan979
  Service that waits for another program to terminate hhh 1 2,542 Dec-15-2017, 01:39 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020