Re: How to terminate the function that runs every n seconds

2015-01-15 Thread Marko Rauhamaa
Marko Rauhamaa : > Dennis Lee Bieber : >> My response to that then is: design the thread's I/O so that it >> is not blocking... On Linux, maybe a timed select(); Windows? short >> sleeps around a non-blocking check for available data... (if console >> I/O, msvcrt.kbhit(); otherwise may need so

Re: How to terminate the function that runs every n seconds

2015-01-15 Thread Marko Rauhamaa
Dennis Lee Bieber : > On Thu, 15 Jan 2015 11:34:54 +0200, Marko Rauhamaa >>Alas, a thread can't check anything because it's blocked by I/O. > > My response to that then is: design the thread's I/O so that it > is not blocking... On Linux, maybe a timed select(); Windows? short > sleeps arou

Re: How to terminate the function that runs every n seconds

2015-01-15 Thread Marko Rauhamaa
Dennis Lee Bieber : > The main thing to consider is that "killing" a thread doesn't > work well in Python. Instead the thread has to check for some signal > telling it to quit. Alas, a thread can't check anything because it's blocked by I/O. Marko -- https://mail.python.org/mailman/listi

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Frank Millman
"Dennis Lee Bieber" wrote in message news:1j1ebalmgkuskq0ltnv5m4sbm6d3p5f...@4ax.com... > > Pseudo (Python 2.x) code > > def aThread(delay=600.0): #default 10 minutes > while keepRunning: > print "thread triggered at %s" % time.time() > time.sleep(delay) > print "thread w

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Grant Edwards
On 2015-01-14, Mark Lawrence wrote: > On 14/01/2015 17:37, Grant Edwards wrote: >> On 2015-01-14, Mark Lawrence wrote: >> >>> Reminds me of working on Telematics S200/300/4000/5000 telecomms kit in >>> the early 90s where the timers were mains based, so a one hour timer >>> would go off at about

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Mark Lawrence
On 14/01/2015 17:37, Grant Edwards wrote: On 2015-01-14, Mark Lawrence wrote: On 14/01/2015 16:33, Dave Angel wrote: Note that neither Timer nor sleep makes any promises about how accurately it matches the requested time. Reminds me of working on Telematics S200/300/4000/5000 telecomms kit

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Grant Edwards
On 2015-01-14, Mark Lawrence wrote: > On 14/01/2015 16:33, Dave Angel wrote: > >> Note that neither Timer nor sleep makes any promises about how >> accurately it matches the requested time. > > Reminds me of working on Telematics S200/300/4000/5000 telecomms kit in > the early 90s where the timer

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
> Do you want to fix the symptom, fix the problem, or finish a school > assignment? To do the first, make a global variable that contains the time > you want to stop making new threads, and conditionally test it before > calling threading.Timer > I firstly apologise for multiple posts and thanks

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Mark Lawrence
On 14/01/2015 16:33, Dave Angel wrote: Note that neither Timer nor sleep makes any promises about how accurately it matches the requested time. Reminds me of working on Telematics S200/300/4000/5000 telecomms kit in the early 90s where the timers were mains based, so a one hour timer would

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Dave Angel
On 01/14/2015 08:09 AM, Ganesh Pal wrote: Corrected Typos . a) How to I prevent the execution of Print "EXECUTED SLEEP" after 4 seconds ? , current this is running in an infinite loop Please on't top-post. If you want to comment on a message, insert your comments after the portion of

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Mark Lawrence
On 14/01/2015 15:03, Ganesh Pal wrote: This is bit urgent and I all stuck form last few hours :( I'm not inclined to help a person who throws four posts at us in two hours and top posts, sorry. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
This is bit urgent and I all stuck form last few hours :( On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal wrote: > Iam using Linux and Python 2.7 and playing with the threading.Timer module. > > I had the below question on the same. > > (a) How to I prevent the execution the "EXECUTED SLEEP" af

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
I quick modified the code and it now looks like this ,is this ok for termination ? I played with t.canel() it didn't work import threading import time def printit(): print "EXECUTED SLEEP" t = threading.Timer(4, printit) t.start() printit() print "hello" output : Throttling-1# python f

Re: How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
Corrected Typos . >a) How to I prevent the execution of Print "EXECUTED SLEEP" after 4 > seconds ? , current this is running in an infinite loop On Wed, Jan 14, 2015 at 6:37 PM, Ganesh Pal wrote: > Iam using Linux and Python 2.7 and playing with the threading.Timer module. > > I had the be

How to terminate the function that runs every n seconds

2015-01-14 Thread Ganesh Pal
Iam using Linux and Python 2.7 and playing with the threading.Timer module. I had the below question on the same. (a) How to I prevent the execution the "EXECUTED SLEEP" after 4 seconds ? , current this is running in an infinite loop node-1# cat file_01.py import threading import time def