No problems running locally but when on labs using getcurrenttime() is causing issues. getcurrenttime() always seems to be returning the same time, deleting everything in apicache makes the time update once but then it goes back to repeating so it's probably a caching issue.
Code:
import sys, time, pywikibot def main(*args): counter = 0 wiki_site = pywikibot.Site() while counter < 10: counter += 1 print(wiki_site.getcurrenttime().isoformat()) sys.stdout.flush() time.sleep(6) if __name__ == "__main__": main()
Output:
2015-03-28T04:58:27Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z 2015-03-28T04:58:33Z
Note that for some reason the first output time is different than the rest. Using siteinfo.get gives a consistent time which updates every time the program is run, but not throughout the program's runtime.
Code:
import sys, time, pywikibot def main(*args): pywikibot.handle_args(args) counter = 0 wiki_site = pywikibot.Site() while counter < 10: counter += 1 print(wiki_site.siteinfo.get('time', get_default=False, cache=False, expiry=0)) sys.stdout.flush() time.sleep(6) if __name__ == "__main__": main()
The code above works if you make _is_expired from line 1220 of site.py always return true so the issue may be related to it not correctly identifying what is and isn't considered expired, not sure why there is a difference between labs and local.