commit: 32864bb166f3a85b4663d93b2a9f03832626bb4f
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 12 17:50:40 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed Oct 12 17:51:19 2022 +0000
URL:
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=32864bb1
runners: add sequential runner
Add a special runner which is run only on main process, and after the
synchronous runners. This is useful for runners which must not be run
in parallel, like the git checks.
Resolves: #326
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcheck/pipeline.py | 10 ++++++++--
src/pkgcheck/runners.py | 9 +++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/pkgcheck/pipeline.py b/src/pkgcheck/pipeline.py
index 9c83ffdb..0dd8f9b4 100644
--- a/src/pkgcheck/pipeline.py
+++ b/src/pkgcheck/pipeline.py
@@ -77,7 +77,7 @@ class Pipeline:
def _create_runners(self):
"""Initialize and categorize checkrunners for results pipeline."""
- pipes = {'async': [], 'sync': []}
+ pipes = {'async': [], 'sync': [], 'sequential': []}
# use addon/source caches to avoid re-initializing objects
addons_map = {}
@@ -96,7 +96,7 @@ class Pipeline:
# Initialize checkrunners per source type using separate runner for
# async checks and categorize them for parallelization based on the
# scan and source scope.
- runners = {'async': defaultdict(list), 'sync': defaultdict(list)}
+ runners = {'async': defaultdict(list), 'sync': defaultdict(list),
'sequential': defaultdict(list)}
for (source, runner_cls), check_objs in checks.items():
runner = runner_cls(self.options, source, check_objs)
if not self.options.pkg_scan and source.scope >=
base.package_scope:
@@ -227,6 +227,12 @@ class Pipeline:
self._queue_work(sync_pipes, work_q)
pool.join()
+ if sequential_pipes := self._pipes['sequential']:
+ for _scope, restriction, pipes in sequential_pipes:
+ for runner in chain.from_iterable(pipes.values()):
+ if results := tuple(runner.run(restriction)):
+ self._results_q.put(results)
+
if async_proc is not None:
async_proc.join()
# notify iterator that no more results exist
diff --git a/src/pkgcheck/runners.py b/src/pkgcheck/runners.py
index b87cafb8..b1aa8e64 100644
--- a/src/pkgcheck/runners.py
+++ b/src/pkgcheck/runners.py
@@ -92,6 +92,15 @@ class RepoCheckRunner(SyncCheckRunner):
yield from check.finish()
+class SequentialCheckRunner(SyncCheckRunner):
+ """Generic runner for sequential checks.
+
+ Checks that must not be run in parallel, will be run on the main process.
+ """
+
+ type = 'sequential'
+
+
class AsyncCheckRunner(CheckRunner):
"""Generic runner for asynchronous checks.