[datafeed] we should use utc timestamp to avoid pb with local times stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 26 May 2011 18:24:41 +0200
branchstable
changeset 7443 c10164464afc
parent 7437 a1f48d7c8a03
child 7444 9bb8f89fd31c
child 7448 195b24fe3a03
[datafeed] we should use utc timestamp to avoid pb with local times
server/sources/datafeed.py
--- a/server/sources/datafeed.py	Wed May 25 14:08:29 2011 +0200
+++ b/server/sources/datafeed.py	Thu May 26 18:24:41 2011 +0200
@@ -118,7 +118,7 @@
     def fresh(self):
         if self.latest_retrieval is None:
             return False
-        return datetime.now() < (self.latest_retrieval + self.synchro_interval)
+        return datetime.utcnow() < (self.latest_retrieval + self.synchro_interval)
 
     def pull_data(self, session, force=False, raise_on_error=False):
         if not force and self.fresh():
@@ -150,7 +150,7 @@
             for etype, eids in byetype.iteritems():
                 session.execute('DELETE %s X WHERE X eid IN (%s)'
                                 % (etype, ','.join(eids)))
-        self.latest_retrieval = datetime.now()
+        self.latest_retrieval = datetime.utcnow()
         session.execute('SET X latest_retrieval %(date)s WHERE X eid %(x)s',
                         {'x': self.eid, 'date': self.latest_retrieval})
         return parser.stats