[docs] PYTHON Principal error - loss of coherence - observed in modules time, datetime

michal.sourek at centrum.cz michal.sourek at centrum.cz
Fri Oct 21 17:10:28 CEST 2011


Dear sirs,
        first,
        let me express a highest level of admiration for all the genuine people involved in Python world
 
        second,
        please forgive me, as an "informed amateur", to direct this notice to you, instead of may-be a specialised dev/error team
 
        third,
        might be, that this piece of information has already been handled in some other bug/error/PEP
 
after some years spent with Python
I´ve observed recently an incoherence - a feature in time / datetime modules,
that,
in a fair belief,
both should and can be handled
so that the function are coherent - meaning the "promised" behaviour keeps really "being delivered" even under bellow-described circumstances, that are quite common in recent years
 
 In a hope
 this can help
 please forward the not to the appropriate hands
 and let me know if it did help - thank you
 
 
With respect
Michal
 
use scenario: a procedure loopLineDATA( anObj ) ...demo-ed bellow ... gets an object to monitor
 and each 10-secs performs regular processing,
 it uses several about-one-second time.sleep()-s to wait till next 10-sec-time-period
 
the point: as gets up and running ( loop forever )
 it prints every 10 secs a "status-report" on time/data
 and
 once
 a notebook gets "hibernated" .. a quite often state ( be it a power saving policy, or an intention )
 the process persists in some state throughout the hibernation epoch
 and after the notebook gets re-activated, the process continues
 
the issue / non-conformity-note [NCN]
 The [NCN] claims,
 that after continuing the processing ( post-hibernation state ),
 Python displays [ uses and displays ]
 wrong time values (as if no hibernation epoch did appear  ... continuing second-by-second right ahead from "old"-time of the moment, when the machine turned hibernated )
 the hibenrated-time-shift is correctly reported by machine clock,
 but not in the Python time / datetime functions - those keep continue counting time as if there were no hibernate-epoch ( areal-wolrd time-shift ) in the meantime
 
an interim fix: to prevent such, perform 
 at some reasonable frequency, to keep low latency/overhead thereof,
 time-base re-adjustment to renew the coherence of Python-time with the machine RTC-clock (real-world-time)
 
" /*-------------------------------------------------------------------
# a demonstration sample ... not any kind of an optimised / HiPerf code :o)
import time, datetime


def loopLineDATA ( anObj )
 last_N = 0
 while True:
 try:
 now = datetime.datetime.now()
 ntt = now.timetuple()
 N   = ntt.tm_sec
 if ( N % 10 ) == 0: # to get 00 10 20 30 .. 50 "round-values"
 if N/ 10 == last_N: # to sleep/loop, should still in the "same-10-sec-time-period"
 time.sleep( 0.95 ) # to provide system a slight time-elasticity for SIG/overhead processing
 else:
 last_N = N / 10 # shuffle N as "10-sec-time-period" 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20111021/11c59d35/attachment.html>


More information about the docs mailing list