pywikibot

pywikibot.exceptions.TimeoutError - how to modify the default


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?


Solution

  • 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 ...