jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326382?usp=email )
Change subject: archivebot: Recreate async executor per template
......................................................................
archivebot: Recreate async executor per template
BoundedPoolExecutor replaced a per-template executor factory with a
single reusable instance. The first template shut it down, so async
processing failed when a second template submitted work.
Create a fresh bounded executor for each template and cover
multi-template async processing.
Change-Id: I3a2096f11d7acfd6e7a7ec2b30f64b7ee4cbc45d
---
M scripts/archivebot.py
M tests/archivebot_tests.py
2 files changed, 22 insertions(+), 3 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 3d9d9cf..ac1915e 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -1104,9 +1104,6 @@
if asynchronous:
signal.signal(signal.SIGINT, signal_handler)
- context = BoundedPoolExecutor('ThreadPoolExecutor')
- else:
- context = nullcontext()
for template_name in templates:
tmpl = pywikibot.Page(site, template_name, ns=10)
@@ -1127,6 +1124,11 @@
botargs = tmpl, salt, force, keep, sort
botkwargs = {'asynchronous': asynchronous}
+ if asynchronous:
+ context = BoundedPoolExecutor('ThreadPoolExecutor')
+ else:
+ context = nullcontext()
+
with context as executor:
for pg in gen:
if asynchronous:
diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py
index 79dac90..8629680 100755
--- a/tests/archivebot_tests.py
+++ b/tests/archivebot_tests.py
@@ -109,6 +109,23 @@
self.assertEqual(environ['TZ'], 'UTC')
tzset.assert_called_once_with()
+ @patch.object(archivebot.pywikibot, 'handle_args',
+ side_effect=lambda args: args)
+ @patch.object(archivebot.signal, 'signal')
+ @patch.object(archivebot, 'process_page')
+ @patch.object(archivebot.pywikibot, 'Page')
+ @patch.object(archivebot.pywikibot, 'Site')
+ def test_async_processes_multiple_templates(
+ self, site_mock, page_mock, process_page_mock, signal_mock,
+ handle_args_mock,
+ ) -> None:
+ """Test async processing with more than one template."""
+ archivebot.main(
+ '-async', '-page:Talk:Sandbox', 'Template:One', 'Template:Two')
+
+ self.assertEqual(process_page_mock.call_count, 2)
+ signal_mock.assert_called_once()
+
def test_get_params_reuses_isocalendar(self) -> None:
"""Test that the ISO calendar is calculated once."""
date = datetime(2024, 12, 30)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326382?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3a2096f11d7acfd6e7a7ec2b30f64b7ee4cbc45d
Gerrit-Change-Number: 1326382
Gerrit-PatchSet: 4
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]