[Tutor] setting up a timer
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Tue, 2 Jul 2002 14:03:18 -0700 (PDT)
On Tue, 2 Jul 2002, Lloyd Kvam wrote:
> I have some logic for starting and connecting to a MySQL database that I
> believe could get stuck because of network problems or remote server
> problems. I'd like to have a timer to simply cancel the process if it
> is not successful in a reasonable time frame. My search didn't turn up
> any examples, so I coded the following (my unix/C roots are showing).
>
> Then I discovered that signal.alarm is NOT available in Windows. Mark
> Hammond's book (Python Programming on Win32) was no help.
>
> Please point me in the right direction.
Hi Lloyd!
There's a "Timer" class in the threading module that might be useful: it
uses threads underneath, so it should be usable with Windows:
http://python.org/doc/current/lib/timer-objects.html
Hope this helps!