473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using Timer incorrectly

I am using a timer in an alarm clock application I am writing. I don't seem to understand how to use the timer.

Expand|Select|Wrap|Line Numbers
  1. import threading
  2.  
  3. class MyClass:
  4.  
  5.  
  6.     def __init__(self):
  7.         self.t = threading.Timer(1, whatever)
  8.         self.t.start()
  9.  
  10.     def whatever(self):
  11.         print  "you got here!"
  12.         return
Can someone tell me where I am going wrong?
Jan 22 '08 #1
3 1389
the Timer object counts down. For example, threading.Timer(60.0,whatever).start()
would wait 60 seconds than execute whatever.

the example you provide is only waiting 1 second before executing, may seem almost instantanious.
Jan 22 '08 #2
the Timer object counts down. For example, threading.Timer(60.0,whatever).start()
would wait 60 seconds than execute whatever.

the example you provide is only waiting 1 second before executing, may seem almost instantanious.
Oh, Timers just countdown once? I assumed they executed a method every x seconds. Was I wrong?
Jan 22 '08 #3
Sorry for taking so long to reply, been away from home for a few days.

Yes, Timers only execute once. I suppose you can get around this by making your own class that uses the Timer object, and repeats the timer a certain ammount of times.
Jan 26 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Alex Fitzpatrick | last post by:
Just by way of introduction, I'm currently the principal developer and maintainer of the a JavaScript editor plug-in for Eclipse. https://sourceforge.net/projects/jseditor/ The plug-in as it...
3
by: ray | last post by:
Hi, I just wrote a windows service application to call a function of another object periodically. I used System.Server.Timer and I found that it works fine within the first 2 hours but the...
18
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
4
by: archana | last post by:
Hi all, I want to develop one windows service in which i want to provide some scheduling facility. What i want is to take start time frm one xml file and then at that specified start time. ...
2
by: janama | last post by:
Hi all, Using wx When adding a second timer as i have the first, the second timer adding stops the first timer (updating or stops?) . In this example im updating a uptime and localtime label....
4
by: Lauren Quantrell | last post by:
I have just put together a vb.net app and now need to provide it to users. This application needs to run the code in a sub every 60 seconds from a Windows Service application. I have the...
2
by: Amit Dedhia | last post by:
Hi I am developing a scientific application which has moderate level image processing involved. In my application, there is a main application form which invokes another form. When this form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.