Page MenuHomePhabricator

Site.server_time sometimes returns a wrong timestamp on the first call.
Closed, ResolvedPublic


Run the following script:

from pywikibot import *
from time import *
s = Site('en', 'wikipedia')



Second and third timestamps make sense, but the first one should only be a few seconds earlier. It seems that the cached result is being returned for the first call by mistake.

Event Timeline

I think the root cause of the issue is that sometimes the general SiteInfo is loaded using a CachedRequest from a cache file, but gets a new timestamp.

We should change Siteinfo class to make it not update timestamps when loading from a CachedRequest or update it with a correct timestamp. Therefore, we may need to change CachedRequest and related calls somehow to return the the cache time to SiteInfo.

Dalba renamed this task from Site.server_time caches the results and returns wrong results in the next call. to Site.server_time sometimes returns a wrong timestamp on the first call..Aug 20 2018, 5:20 AM

Change 453944 had a related patch set uploaded (by Dalba; owner: dalba):
[pywikibot/core@master] Cleanup the code in site.SiteInfo

Change 453944 merged by jenkins-bot:
[pywikibot/core@master] Fix the bug in cache_time when loading a CachedRequest