Python Forum
Is there a way to not terminate a running thread in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to not terminate a running thread in python
#2
There are a couple ways, both of which use the time library. First you'll need to import time. The first method is time.sleep(seconds), which is very simple, but sometimes you may need to do something else to run code while waiting. Here's some example code of the other method.
import time

timeStamp = time.time() #Records a number measured in epoch time
waitTime = 10

while time.time() - timeStamp < waitTime:
    #Run code here
Hope this helps
Reply


Messages In This Thread
RE: Is there a way to not terminate a running thread in python - by SheeppOSU - May-04-2020, 10:12 PM

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,476 Jul-22-2021, 03:24 AM
Last Post: rango
  Pyinstaller keeps thread running pythonuser_0101 2 3,178 Mar-06-2020, 02:09 PM
Last Post: pythonuser_0101
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,687 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE
  Terminate a process when hotkey is pressed 66Gramms 0 2,271 Dec-24-2019, 06:41 PM
Last Post: 66Gramms
  How to terminate the caller fuction through callee? 100k 2 2,199 Nov-27-2019, 06:49 PM
Last Post: jefsummers
  How to terminate a list of inputs with a set value? SOS Manning 2 2,223 Sep-19-2019, 01:54 AM
Last Post: scidam
  Python Thread stops execution neethuvp 1 3,441 Feb-18-2019, 06:36 PM
Last Post: micseydel
  Debugging inside a thread with Python 2.3.4 zerajera 0 1,718 Nov-21-2018, 01:43 PM
Last Post: zerajera
  Is thread running? MuntyScruntfundle 0 2,108 Oct-19-2018, 06:10 PM
Last Post: MuntyScruntfundle
  how to terminate all the processes in C py2exe 0 2,096 Aug-02-2018, 04:31 AM
Last Post: py2exe

Forum Jump:

User Panel Messages

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