Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python how to restart thread

# You can not restart a thread in python
# However you can make sure it stays alive forever
# If threads ending is a problem just loop them forever

# Example:
import threading
import time

class mythreader(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.setDaemon(True)
        self.running = True
        self.start()
        
    def run(self):
        mycounter = 0
        while self.running:
			do_some_cool_stuff()
            time.sleep(2)
Comment

PREVIOUS NEXT
Code Example
Python :: python docstring 
Python :: Python NumPy delete Function Example Deletion from 1D array 
Python :: python list comprehension with filter 
Python :: keras transfer learning 
Python :: heroku how to access config vars django 
Python :: remove first element from list python 
Python :: insert in python 
Python :: access list index python 
Python :: geodataframe get crs 
Python :: object oriented python 
Python :: replace nan from another column 
Python :: Program to Compute LCM Using GCD 
Python :: python remove  
Python :: python convert np datetime to string 
Python :: control flow in python 
Python :: how to get list size python 
Python :: polls/models.py 
Python :: handling exceptions 
Python :: Python NumPy ndarray flatten Function Syntax 
Python :: scale in numpy 
Python :: best jarvis code in python 
Python :: python string after character 
Python :: import python module 
Python :: search method in python 
Python :: python while loop 
Python :: dataframe names pandas 
Python :: python list remove 
Python :: Heroku gunicorn flask login is not working properly 
Python :: deactivate pandas warning copy 
Python :: quadrilateral 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =