win32 service and time.sleep()
steve at holdenweb.com
Tue Sep 20 17:50:32 CEST 2005
> I have a win32 service written in Python. It works well. It sends a
> report of the status of the machine via email periodically. The one
> problem I have is this... while trying to send an email, the script
> loops until a send happens and then it breaks. Should it be unable to
> send, it sleeps for 10 minutes with time.sleep(600) and then wakes and
> tries again. This is when the problem occurs. I can't stop the service
> while the program is sleeping. When I try, it just hangs until a reboot.
> Can some suggest how to fix this?
One way would be to maintain a Queue.Queue containing the messages that
need to be sent and, rather than sleeping to retry just retrying when
enough time has elapsed. That way you can keep pumping messages and so
on to your heart's content, though you will have to keep track of the
messages still to be sent.
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.pycon.org
More information about the Python-list