0

in my github actions unit test i am running some pywikibot code (pywikibot 6.6.3) that some times fails due to the site not being responsive or a misconfiguration. The log report used to show the error messages after a few minutes.

Now the code runs some 2 hours and more with hint such as:

...  Waiting 120.0 seconds before retrying.

 File "/opt/hostedtoolcache/Python/3.9.7/x64/lib/python3.9/site-packages/pywikibot/data/api.py", line 1883, in wait
Error:     raise TimeoutError('Maximum retries attempted without success.')
pywikibot.exceptions.TimeoutError: Maximum retries attempted without success.

But there is no mention how to change the retries and timeout values?

I found the source code at https://github.com/wikimedia/pywikibot/blob/master/pywikibot/data/api.py

But since the api init is called indirectly i need to know how the configuration is to be done to get less retries and quicker timeout

https://stackoverflow.com/a/39062902/1497139

even has a precise hint what to change but no source code example for this so i still don't know what the python code should look to modify outside of the config file during the initialization phase.

How could i change the settings to get a quick fail mode which is appropriate for the tests?

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186

1 Answers1

0

the style of setting the variables is:

import pywikibot

pywikibot.config.max_retries=2

I was just not believing that the wikimedia foundation still uses global variables for configuration ...

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
  • These setting variables are described at the documentation and can be set in the user-config.py or as command line setting e.g. -max_retries:2 https://doc.wikimedia.org/pywikibot/stable/api_ref/pywikibot.config.html?#settings-to-avoid-server-overload – xqt Dec 29 '21 at 13:18
  • @xqt - i am neither using the command line nor the user-config.py - i am trying to use the API directly after these two options have been applied. – Wolfgang Fahl Dec 29 '21 at 14:38
  • Our test does it in the same manner and set config.max_retries directly: https://gerrit.wikimedia.org/r/plugins/gitiles/pywikibot/core/+/4fc8972c2a94e29905974f38b9b400b14d68e10e/tests/__init__.py – xqt Dec 30 '21 at 07:56