Make a function call itself after set amount of time

Bart Nessux bart_nessux at hotmail.com
Tue Jan 13 15:26:01 EST 2004


Peter Otten wrote:
> Bart Nessux wrote:
> 
> 
>>Bart Nessux wrote:
>>
>>>How do I make a function call itself every 24 hours. Also, is there a
>>>way to start the program automatically w/o depending on the OS functions
>>>like 'Task Scheduler' or 'Start Up Items'... this is on Windows 2k and
>>>xp. Below is an example of what I'm trying to do.
> 
> 
> [...]
> 
> 
>>I figured it out. I added this to the function definition:
>>ipconfig_email()
> 
> 
> Note that Python has a limit for nesting functions:
> 
> 
>>>>depth = 0
>>>>def callself():
> 
> ...     global depth
> ...     depth += 1
> ...     callself()
> ...
> 
>>>>try:
> 
> ...     callself()
> ... except RuntimeError, e:
> ...     print "depth", depth
> ...     print e
> ...
> depth 999
> maximum recursion depth exceeded
> 
> 
>>>>999/365.25
> 
> 2.7351129363449691
> 
> This means that your app will probably crash in less than three years.
> Would that be a problem on W2K ?
> 
> If so, a loop could go much longer:
> 
> while True:
>     ipconfig_email()
> 
> Seriously, you should reconsider the OS features.
> 
> Peter
> 

The computers are turned off and on... the script starts at boot. I 
don't think I'll hit a limit, do you?




More information about the Python-list mailing list