pass sleep (1), , , - 12:30:59.99999, 12:31:01.00001.
. , , . .
- Python , :
from datetime import datetime
from time import sleep
def WaitForNextMinute():
secs = datetime.utcnow().second
while secs < 57:
sleep (57 - secs)
secs = datetime.utcnow().second
while datetime.utcnow().second >= 57:
sleep (1)
while True:
WaitForNextMinute()
print datetime.utcnow()
:
2012-08-25 04:16:00.111257
2012-08-25 04:17:00.157155
2012-08-25 04:18:00.217356
2012-08-25 04:19:00.270348
2012-08-25 04:20:00.330203
2012-08-25 04:21:00.390318
2012-08-25 04:22:00.450440
2012-08-25 04:23:00.510491
2012-08-25 04:24:00.570487
2012-08-25 04:25:00.630502
2012-08-25 04:26:00.690523
2012-08-25 04:27:00.750642
2012-08-25 04:28:00.810780
2012-08-25 04:29:00.870900
2012-08-25 04:30:00.931078
, .
, , , .
, , , 12:21:13. secs , 57, 57 - 13 , 12:21:57.
, second 57. , .
, , , .
And if you want you to get as close as possible to the minute survey, you can replace sleep (1)with pass. Thus, you will work with a full CPU rollback for no more than three seconds out of sixty (an average of 5%) and get as close as possible to a minute rollover.
When I do this small modification, I get:
2012-08-25 05:48:00.000003
2012-08-25 05:49:00.000003
2012-08-25 05:50:00.000003
2012-08-25 05:51:00.000004
2012-08-25 05:52:00.000004
2012-08-25 05:53:00.000004
2012-08-25 05:54:00.000003
2012-08-25 05:55:00.000004
source
share