Make a function call itself after set amount of time

Peter Otten __peter__ at
Tue Jan 13 20:18:54 CET 2004

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

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:

Seriously, you should reconsider the OS features.


More information about the Python-list mailing list