I have a function:
def threaded(fn):
def wrapper(*args, **kwargs):
thread = threading.Thread(target=fn, args=args, kwargs=kwargs)
thread.start()
return thread
return wrapper
And a class:
class someclass(somestuff):
def __init__(self, parent=None):
super(thing)
.
.
.
@threaded
def start_thread(self):
while True:
self.update_watchers()
def update_watchers(self):
.
.
.
def otherfunctions(self):
.
.
.
.
And in my main:
obj = someclass()
handle = obj.start_thread()
handle.join()
Now, if I take the while
loop out of start_thread
, everything works fine. I suspect I am using forever-threads long (a forever thread is a thread that runs as long as the program is running, of course).
As an FYI, this program occupies a list. Not a Python list, a GUI list. It looks into a file that is constantly being updated. update_watchers()
updates the watchers I have running over the file, extracts information when (for example) the program is paused (which is one of the several reasons why I need a thread).
Can someone explain to me what is going on? It keeps breaking when I get to handle
's definition. I know I must be using the While loop wrong and there is a correct way to do it. I need start_thread to run all the time because I need update_watchers to be running all the time.
I cant really post more code than that.
Thank you
Edit: threaded
function taken from this post