[PATCH 3/3] DNFPayload: error handling and logging cleanups.

Vratislav Podzimek vpodzime at redhat.com
Mon Oct 14 07:37:07 UTC 2013


On Fri, 2013-10-11 at 14:38 +0200, Ales Kozumplik wrote:
> From: Ales Kozumplik <ales at redhat.com>
> 
> ---
>  pyanaconda/packaging/dnfpayload.py | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
> index a9900e6..fe84e7f 100644
> --- a/pyanaconda/packaging/dnfpayload.py
> +++ b/pyanaconda/packaging/dnfpayload.py
> @@ -80,7 +80,7 @@ def do_transaction(base, queue):
>      except BaseException as e:
>          log.error('The transaction process has ended abruptly')
>          log.info(e)
> -        queue.put('quit', str(e))
> +        queue.put(('quit', str(e)))
>  
>  class DNFPayload(packaging.PackagePayload):
>      def __init__(self, data):
> @@ -104,10 +104,12 @@ class DNFPayload(packaging.PackagePayload):
>          repo.sslverify = not (ksrepo.noverifyssl or flags.noverifyssl)
>          repo.enable()
>          self._base.repos.add(repo)
> +        log.info("added repo: '%s'", ksrepo.name)
>  
>      def _apply_selections(self):
>          self._select_group('core')
>          for pkg_name in self.data.packages.packageList:
> +            log.info("selecting package: '%s'", pkg_name)
>              try:
>                  self._install_package(pkg_name)
>              except packaging.NoSuchPackage as e:
> @@ -263,10 +265,9 @@ class DNFPayload(packaging.PackagePayload):
>          self._base.reset(goal=True)
>          self._apply_selections()
>  
> -        log.info("checking dependencies")
>          try:
>              if self._base.build_transaction():
> -                log.debug("success")
> +                log.debug("checking dependencies: success.")
>              else:
>                  log.debug("empty transaction")
>          except dnf.exceptions.DepsolveError as e:
> @@ -346,15 +347,19 @@ class DNFPayload(packaging.PackagePayload):
>  
>          queue = multiprocessing.Queue()
>          process = multiprocessing.Process(target=do_transaction,
> -                                          args=(self._base,queue))
> +                                          args=(self._base, queue))
>          process.start()
>          (token, msg) = queue.get()
> -        while token != 'post':
> +        while token not in ('post', 'quit'):
>              if token == 'install':
>                  msg = _("Installing %s") % msg
>                  progressQ.send_message(msg)
>              (token, msg) = queue.get()
>  
> +        if token == 'quit':
> +            progressQ.send_quit(1)
> +            sys.exit(1)
The installation thread shouldn't exit the process. It should just send
the quit message and wait for the main thread to quit the process. I
know we have both things in the yumpayload.py module, but those
sys.exit() calls are bugs (I'll send a patch soon). Just replace it
with:

while True:
    time.sleep(10000)

Otherwise these all look good to me.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list