Threading and Queuing with Functions Threading and Queuing with Functions tkinter tkinter

Threading and Queuing with Functions


The problem is that you are not calling the function when you use it as an argument for ThreadedClient1:

class ThreadedClient1(threading.Thread):    # ...    def run(self):        time.sleep(1)        self.queue.put(lambda: self.fcn)

It is just a function that returns a reference to the lambda you pass as an argument, NOT the result of the call to slxl.runImportAndCoordAdder(). It should be:

class ThreadedClient1(threading.Thread):    # ...    def run(self):        time.sleep(1)        self.queue.put(self.fcn())

Or another solution with the reference directly (without lambdas):

def spawnthread(self):    self.updatebttn.config(state="disabled")    self.thread = ThreadedClient1(self.queue, slxl.runImportAndCoordAdder)    self.thread.start()    self.periodiccall()class ThreadedClient1(threading.Thread):    # ...    def run(self):        time.sleep(1)        self.queue.put(self.fcn())