jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1022548?usp=email )
Change subject: [fix] Increase read timeout for alllinks tests. ......................................................................
[fix] Increase read timeout for alllinks tests.
Using *namespace* option different from ``0`` needs a lot of time on Wikidata site. Increase this value to 60s for tests and add an important note to documentation.
Bug: T359427 Change-Id: I0b6c56883612fb165b9b792bcc00323d0a25b41a --- M pywikibot/site/_generators.py M tests/site_generators_tests.py 2 files changed, 29 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py index eaed600..4b48de3 100644 --- a/pywikibot/site/_generators.py +++ b/pywikibot/site/_generators.py @@ -428,7 +428,9 @@ ) -> Generator[pywikibot.Page, None, None]: """Yield internal wikilinks contained (or transcluded) on page.
- .. seealso:: :api:`Links` + .. seealso:: + - :api:`Links` + - :meth:`page.BasePage.linkedPages`
:param namespaces: Only iterate pages in these namespaces (default: all) @@ -993,7 +995,27 @@ :func:`tools.itertools.filter_unique` in that case which might be memory intensive. Use it with care.
- .. seealso:: :api:`Alllinks` + .. important:: Using *namespace* option different from ``0`` + needs a lot of time on Wikidata site. You have to increase + the **read** timeout part of ``socket_timeout`` in + :ref:`Http Settings` in your ``user-config.py`` file. Or + increase it patially within your code like: + + .. code:: pytkon + + from pywikibot import config + save_timeout = config.socket_timeout # save the timeout config + config.socket_timeout = save_timeout[0], 60 + ... # your code here + config.socket_timeout = save_timeout # restore timeout config + + The minimum read timeout value should be 60 seconds in that + case. + + .. seealso:: + - :api:`Alllinks` + - :meth:`pagebacklinks` + - :meth:`pagelinks`
:param start: Start at this title (page need not exist). :param prefix: Only yield pages starting with this string. diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py index 3fae8e7..189943c 100755 --- a/tests/site_generators_tests.py +++ b/tests/site_generators_tests.py @@ -363,10 +363,15 @@ msg=f"{page.title()} does not start with 'Fix'" )
+ # increase timeout due to T359427/T359425 + # ~ 47s are required on wikidata + config_timeout = pywikibot.config.socket_timeout + pywikibot.config.socket_timeout = (config_timeout[0], 60) with self.subTest(msg='Test namespace parameter'): for page in mysite.alllinks(namespace=1, total=5): self.assertIsInstance(page, pywikibot.Page) self.assertEqual(page.namespace(), 1) + pywikibot.config.socket_timeout = config_timeout
with self.subTest(msg='Test with fromids parameter'): for page in mysite.alllinks(start='From', namespace=4,