commit:     b2ba35d4704172e8ddbfa0c98900f4b6ed20416b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 29 20:03:05 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Apr 29 20:03:43 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b2ba35d4

AbstractPollTask: call _unregister in _async_wait (bug 654276)

Subclasses of AbstractPollTask perform idempotent cleanup in
the _unregister method, so it's useful for _async_wait to call it
automatically. This allows for migration of various cleanup code from
_set_returncode to _unregister, for the purposes of bug 654276.

Bug: https://bugs.gentoo.org/654276

 pym/_emerge/AbstractPollTask.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py
index 0ce3594b4..2c5403751 100644
--- a/pym/_emerge/AbstractPollTask.py
+++ b/pym/_emerge/AbstractPollTask.py
@@ -114,8 +114,12 @@ class AbstractPollTask(AsynchronousTask):
 
                return buf
 
+       def _async_wait(self):
+               self._unregister()
+               super(AbstractPollTask, self)._async_wait()
+
        def _unregister(self):
-               raise NotImplementedError(self)
+               self._registered = False
 
        def _log_poll_exception(self, event):
                writemsg_level(
@@ -127,12 +131,10 @@ class AbstractPollTask(AsynchronousTask):
                if self._registered:
                        if event & self._exceptional_events:
                                self._log_poll_exception(event)
-                               self._unregister()
                                self.cancel()
                                self.returncode = self.returncode or os.EX_OK
                                self._async_wait()
                        elif event & self.scheduler.IO_HUP:
-                               self._unregister()
                                self.returncode = self.returncode or os.EX_OK
                                self._async_wait()
 

Reply via email to