Re: [Tutor] While Loop and Threads

2014-07-15 Thread Japhy Bartlett
this construct: On Tue, Jul 15, 2014 at 5:09 AM, Oğuzhan Öğreden wrote: > > > while time_now < time_finish: # counter and count_until defined > somewhere above and > if g_threadStop.is_set() == False: > # return something or raise an exception to signal > ite

Re: [Tutor] While Loop and Threads

2014-07-15 Thread James Chapman
Apologies, I didn't answer your question. while time_now < time_finish: # counter and count_until defined somewhere above and if g_threadStop.is_set() == False: # return something Thread methods are typically void, meaning they return nothing. At least this is

Re: [Tutor] While Loop and Threads

2014-07-15 Thread James Chapman
So if I understand this correctly, you want to start a thread and then stop it after a certain time period? Here's an adapted example that includes a timer. (I believe in learning by example where possible) With that said, if it were my code going into production I'd move the timer logic out of th

Re: [Tutor] While Loop and Threads

2014-07-15 Thread Oğuzhan Öğreden
Thanks! I'll have a side question. If I implement this idea to my case, threadWorker() would look like this: def threadWorker(_arg1, _arg2): print("Starting worker thread with args: %s, %s" % (_arg1, _arg2)) while g_threadStop.is_set() == False: ## here comes a for loop:

Re: [Tutor] While Loop and Threads

2014-07-14 Thread James Chapman
OK, so I mocked up an example now... import time import threading g_threadStop = threading.Event() def threadWorker(_arg1, _arg2): print("Starting worker thread with args: %s, %s" % (_arg1, _arg2)) while(not g_threadStop.is_set()): print("Thread running.") time.sleep(1)

Re: [Tutor] While Loop and Threads

2014-07-14 Thread James Chapman
Multi-threading takes practice! Are you using an event object to signal the thread should exit? I'm guessing you're just using a bool which is why it does not work. See: https://docs.python.org/3.4/library/threading.html#event-objects I'm very short on time and the moment and therefore can't moc

[Tutor] While Loop and Threads

2014-07-13 Thread Oğuzhan Öğreden
Hi, I've been practicing with multithreading and gtk for a while and recently have observed something I can't quite grasp. This is basically a timer with a settings window and a countdown window which is produced after setting_window passes necessary arguments to thread. I have a while loop whic