From 687000cd2512155bde70d71df65ba9b88673ae4b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 16 Oct 2012 15:45:17 -0700 Subject: [PATCH] ManifestTask: remove unneeded _proc attribute It's enough to reference the PopenProcess instance as self._current_task while it's alive (CompositeTask._cancel() can kill it via this). --- .../ebuild/_parallel_manifest/ManifestTask.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py b/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py index 83ef89094..bfa7bd7f0 100644 --- a/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py +++ b/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py @@ -19,8 +19,7 @@ from .ManifestProcess import ManifestProcess class ManifestTask(CompositeTask): __slots__ = ("cp", "distdir", "fetchlist_dict", "gpg_cmd", - "gpg_vars", "repo_config", "force_sign_key", "_manifest_path", - "_proc") + "gpg_vars", "repo_config", "force_sign_key", "_manifest_path") _PGP_HEADER = b"BEGIN PGP SIGNED MESSAGE" _manifest_line_re = re.compile(r'^(%s) ' % "|".join(MANIFEST2_IDENTIFIERS)) @@ -33,11 +32,6 @@ class ManifestTask(CompositeTask): scheduler=self.scheduler) self._start_task(manifest_proc, self._manifest_proc_exit) - def _cancel(self): - if self._proc is not None: - self._proc.cancel() - CompositeTask._cancel(self) - def _manifest_proc_exit(self, manifest_proc): self._assert_current(manifest_proc) if manifest_proc.returncode not in (os.EX_OK, manifest_proc.MODIFIED): @@ -65,14 +59,13 @@ class ManifestTask(CompositeTask): self._start_gpg_proc() def _check_sig_key(self): - self._proc = PopenProcess(proc=subprocess.Popen( + popen_proc = PopenProcess(proc=subprocess.Popen( ["gpg", "--verify", self._manifest_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT), - pipe_reader=PipeReader(scheduler=self.scheduler), - scheduler=self.scheduler) - self._proc.pipe_reader.input_files = { - "producer" : self._proc.proc.stdout} - self._start_task(self._proc, self._check_sig_key_exit) + pipe_reader=PipeReader()) + popen_proc.pipe_reader.input_files = { + "producer" : popen_proc.proc.stdout} + self._start_task(popen_proc, self._check_sig_key_exit) @staticmethod def _parse_gpg_key(output): @@ -90,7 +83,6 @@ class ManifestTask(CompositeTask): def _check_sig_key_exit(self, proc): self._assert_current(proc) - self._proc = None parsed_key = self._parse_gpg_key( proc.pipe_reader.getvalue().decode('utf_8', 'replace')) if parsed_key is not None and \ @@ -100,6 +92,10 @@ class ManifestTask(CompositeTask): self.wait() return + if self._was_cancelled(): + self.wait() + return + self._strip_sig(self._manifest_path) self._start_gpg_proc() -- 2.26.2