Pywikibot accepts API maxlag. If maxlag is above 5 s threshold (commons to all Wikimedia wikis), Pywikibot waits with requests until maxlag drops. Average Wikidata API maxlag has been [[https://grafana.wikimedia.org/d/000000156/wikidata-dispatch?orgId=1&refresh=1m&from=1566387815137&to=1574167415137&var-dispatchServerDatasource=eqiad%20prometheus%2Fops&var-dispatchServer=mwmaint1002&fullscreen&panelId=22|650 ms]] (similar to any other Wikimedia wiki), so this has never been an issue until now.
# On 20th Nov, 2019 Wikidata API maxlag jumped from average 650 ms to average 2.2 s. This happened possibly due to {T221774}. Since then maxlag was repeatedly getting close to [[https://grafana.wikimedia.org/d/000000156/wikidata-dispatch?orgId=1&refresh=1m&from=1574340289485&to=1579610689486&var-dispatchServerDatasource=eqiad%20prometheus%2Fops&var-dispatchServer=mwmaint1002&fullscreen&panelId=22|5 s threshold]]. It was still fine though, as the 5 s threshold has been exceeded only few times.
# On 20th Jan, 2020 Wikidata API maxlag jumped once again from average 2.2 s to average 4.9 s. The cause of the jump is still unknown to this date. The 5 s threshold has been [[https://grafana.wikimedia.org/d/000000156/wikidata-dispatch?orgId=1&refresh=1m&from=1579525375573&to=1581339775574&var-dispatchServerDatasource=eqiad%20prometheus%2Fops&var-dispatchServer=mwmaint1002&fullscreen&panelId=22|exceeded almost every day]] since then. This causes several issues to occur during peak time:
#- users are unable to use Pywikibot with Wikidata: T242081#5853949, T244030
#- Pywikibot tests are failing with Timeout: https://travis-ci.org/wikimedia/pywikibot/jobs/633377671#L3591
#- Pywikibot tests are failing with EntityTypeUnknownException (which seems to be a malformed cache because of Timeout on cache's creation): T242083 (https://travis-ci.org/wikimedia/pywikibot/jobs/633377685#L1496)
The #upstream issue is T243701