Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- from threading import Thread
- from threading import Event
- import queue
- sem=threading.Semaphore()
- def setup_for_long_running_task(self):
- print("start")
- self.f1.config(cursor="wait") # Set the cursor to busy
- sem.acquire()
- return_que = queue.Queue(1)
- workThread = Thread(target=lambda q, w_self:
- q.put(self.long_running_task()),
- args=return_que)
- workThread.start()
- self.f1.after(5000,use_results_of_long_running_task(self,workThread,return_que)) # 500ms is half a second
- sem.release()
- print("stop")
- def long_running_task(self):
- Event().wait(3.0) # Simulate long running task
- def use_results_of_long_running_task(self, workThread,return_que):
- ThreadRunning = 1
- while ThreadRunning:
- Event().wait(0.1) # this is set to .1 seconds. Adjust for your process
- ThreadRunning = workThread.is_alive()
- while not return_que.empty():
- return_list = return_que.get()
- self.f1.config(cursor="")
- TypeError: <lambda>() argument after * must be an iterable, not Queue.
- Exception in thread Thread-7:
- Traceback (most recent call last):
- File "C:ProgramDataAnaconda3libthreading.py", line 917, in
- _bootstrap_inner
- self.run()
- File "C:ProgramDataAnaconda3libthreading.py", line 865, in run
- self._target(*self._args, **self._kwargs)
- TypeError: <lambda>() argument after * must be an iterable, not Queue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement