ManifestTask: remove unneeded _proc attribute
authorZac Medico <zmedico@gentoo.org>
Tue, 16 Oct 2012 22:45:17 +0000 (15:45 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 16 Oct 2012 22:45:17 +0000 (15:45 -0700)
It's enough to reference the PopenProcess instance as
self._current_task while it's alive (CompositeTask._cancel() can kill
it via this).

pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py

index 83ef890940d85a6fb2f135bee3fcc570685a46ae..bfa7bd7f0dece42c45ac73f29eab2ce3230bfdf9 100644 (file)
@@ -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()