A question about time
Ivan Shevanski
darkpaladin79 at hotmail.com
Thu Jun 9 17:06:33 EDT 2005
>From: Jan Danielsson <jan.danielsson at gmail.com>
>To: python-list at python.org
>Subject: A question about time
>Date: Thu, 09 Jun 2005 22:58:17 +0200
>
>Hello all,
>
> I have a list of servers which an application connects to. If the
>connection fails, the application should mark the server as temporarily
>unavailable, and should try to use the server again after x units of time.
>
>In C, I would do this:
>
>server.invalidUntil = time(NULL) + 5*60; // five minute delay
>
>..and the check:
>
>if(time(NULL) > server.invalidUtil)
>{
> // use server
>}
>
>So the whole thing very simple... But how do I do that in Python?
>
> I have found datetime.datetime.now(), but I don't understand what
>"format" it returns the time in. I assume it's an object of some sort..
>But how do I do if I want the current time as an integer (unix
>timestamp) in Python?
---
Heres the time module link, use a combination of the modules to get the
complete time. Use time.sleep() to sleep for a certain amount of SECONDS.
Not minutes. So:
>>>from sleep import time
>>>sleep(5)
would have the program or script stop and wait for 5 seconds. I hope this
was what your were asking for, I didn't quite get the question.
-Ivan
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
More information about the Python-list
mailing list