witten
/
luminotes
Archived
1
0
Fork 0

Hack to work around poor timer precision on Windows. This bug prevented Persistent.update_revision() from working consistently.

This commit is contained in:
Dan Helfman 2008-08-21 00:33:19 -07:00
parent a3c13d4edf
commit 3fa1e8f8e6
1 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import time
from datetime import datetime
from pytz import utc
@ -71,7 +72,15 @@ class Persistent( object ):
)
def update_revision( self ):
self.__revision = datetime.now( tz = utc )
revision = datetime.now( tz = utc )
# if the revision didn't change, then we must be using a low-precision timer on a platform like
# Windows. so, replace the microseconds with a value from a higher-precision timer
if revision == self.__revision:
MICROSECONDS = 1000000
revision = revision.replace( microsecond = time.clock() * MICROSECONDS % MICROSECONDS )
self.__revision = revision
@staticmethod
def make_cache_key( Object_type, object_id ):