From: Chris Hare on
I am currently using threading.timer to execute an event in my big chunk of code. This is causing a problem with sqlite, so I am trying to figure out the sched function

import sched
import time

def timerfunc():
print "hello", time.time()
return(time.time())

def delay(period):
time.sleep(period)

def some():
s.enterabs(900,1, timerfunc, () )
s.run()

s = sched.scheduler(timerfunc, delay)

print time.time()
some()
x = 0
while 1:
print x
x = x + 1
time.sleep(60)
print str(s.queue())

What I am trying to do is mimic the Timer function, where my code will continue to function while my scheduled function executes in 15 minutes or 900 seconds. This doesn't do it though. Any help?

From: Chris Hare on


On Aug 7, 2010, at 1:30 AM, Dennis Lee Bieber wrote:

> On Fri, 06 Aug 2010 22:37:26 -0500, Chris Hare <chare(a)labr.net>
> declaimed the following in gmane.comp.python.general:
>
>
>> print str(s.queue())
>>
> I don't find a queue method defined for scheduler objects in the
> documentation for my version of Python (2.5)
>
>> What I am trying to do is mimic the Timer function, where my code will continue to function while my scheduled function executes in 15 minutes or 900 seconds. This doesn't do it though. Any help?
>
> And what IS it doing? On my system, I'd expect the program to fail
> when trying to print whatever that queue() method is supposed to return.
>
> However, here is the key item you seem to have missed -- from the
> documentation:
>
> -=-=-=-=-
> run( )
>
> Run all scheduled events. This function will wait (using the delayfunc
> function passed to the constructor) for the next event, then execute it
> and so on until there are no more scheduled events.
> -=-=-=-=-
>
> As soon as you call s.run() the entire PROGRAM goes into a wait
> state until the first of the queued events time expires. AND won't
> return until ALL events have happened.
>
> To have scheduled events happen asynchronously you will have to
> instantiate a THREAD which runs the scheduler... Of course, for your
> simple example, who needs the scheduler -- a simple sleep() in the
> thread will do what you attempted... The scheduler is useful when you
> want to queue a whole bunch of timed events and have them run in order
> at the set times... maybe even have events add more events to the
> system.
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfraed(a)ix.netcom.com HTTP://wlfraed.home.netcom.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-listThanks Dennis.

I guess I will have to figure out how to resolve the sqlite error