[Notes] [Git][BuildStream/buildstream][tristan/fix-status-messages-1.2] source.py: Silence messages while consuming source fetchers



Title: GitLab

Tristan Van Berkom pushed to branch tristan/fix-status-messages-1.2 at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • buildstream/source.py
    ... ... @@ -585,28 +585,48 @@ class Source(Plugin):
    585 585
         #
    
    586 586
         def _fetch(self):
    
    587 587
             project = self._get_project()
    
    588
    -        source_fetchers = self.get_source_fetchers()
    
    588
    +        context = self._get_context()
    
    589
    +
    
    590
    +        # Silence the STATUS messages which might happen as a result
    
    591
    +        # of checking the source fetchers.
    
    592
    +        with context.silence():
    
    593
    +            source_fetchers = self.get_source_fetchers()
    
    589 594
     
    
    590 595
             # Use the source fetchers if they are provided
    
    591 596
             #
    
    592 597
             if source_fetchers:
    
    593
    -            for fetcher in source_fetchers:
    
    594
    -                alias = fetcher._get_alias()
    
    595
    -                for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
    
    596
    -                    try:
    
    597
    -                        fetcher.fetch(uri)
    
    598
    -                    # FIXME: Need to consider temporary vs. permanent failures,
    
    599
    -                    #        and how this works with retries.
    
    600
    -                    except BstError as e:
    
    601
    -                        last_error = e
    
    602
    -                        continue
    
    603
    -
    
    604
    -                    # No error, we're done with this fetcher
    
    605
    -                    break
    
    606 598
     
    
    607
    -                else:
    
    608
    -                    # No break occurred, raise the last detected error
    
    609
    -                    raise last_error
    
    599
    +            # Use a contorted loop here, this is to allow us to
    
    600
    +            # silence the messages which can result from consuming
    
    601
    +            # the items of source_fetchers, if it happens to be a generator.
    
    602
    +            #
    
    603
    +            source_fetchers = iter(source_fetchers)
    
    604
    +            try:
    
    605
    +
    
    606
    +                while True:
    
    607
    +
    
    608
    +                    with context.silence():
    
    609
    +                        fetcher = next(source_fetchers)
    
    610
    +
    
    611
    +                    alias = fetcher._get_alias()
    
    612
    +                    for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
    
    613
    +                        try:
    
    614
    +                            fetcher.fetch(uri)
    
    615
    +                        # FIXME: Need to consider temporary vs. permanent failures,
    
    616
    +                        #        and how this works with retries.
    
    617
    +                        except BstError as e:
    
    618
    +                            last_error = e
    
    619
    +                            continue
    
    620
    +
    
    621
    +                        # No error, we're done with this fetcher
    
    622
    +                        break
    
    623
    +
    
    624
    +                    else:
    
    625
    +                        # No break occurred, raise the last detected error
    
    626
    +                        raise last_error
    
    627
    +
    
    628
    +            except StopIteration:
    
    629
    +                pass
    
    610 630
     
    
    611 631
             # Default codepath is to reinstantiate the Source
    
    612 632
             #
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]