def execute(self, bundle, max_sec, is_inc=False):
        failed = False
        self.clock = Clock()
        time_exceed = lambda: self.clock.clock() >= max_sec
        
        self.processing_inc = is_inc
        bundle.current_urls = getattr(bundle, 'current_urls', []) \
                                    or bundle.urls()
        bundle.current_urls.extend(getattr(bundle, 'error_urls', []))
        
        while not self.stopped.is_set() and len(bundle.current_urls) > 0 \
            and not time_exceed():
            
            while not self.nonsuspend.wait(5):
                continue
            if self.stopped.is_set():
                break
            
            url = bundle.current_urls.pop(0)
            if self.logger:
                self.logger.debug('get %s url: %s' % 
                                    (bundle.label, url))
            
            rates = 0
            span = 0.0
            parser_cls, options = self.job_desc.url_patterns.get_parser(url, 
                                                                        options=True)
            if parser_cls is not None:
                if rates == 0:
                    rates, span = self.speed_client.require(
                        DEFAULT_SPEEED_REQUIRE_SIZE)
                if rates == 0:
                    if self.stopped.wait(5):
                        break
                rates -= 1
                
                try:
                    next_urls, bundles = self._parse_with_process_exception(
                        parser_cls, options, bundle, url)
                    next_urls = list(self.job_desc.url_patterns.matches(next_urls))
                    next_urls.extend(bundle.current_urls)
                    if self.shuffle_urls:
                        if len(next_urls) > 0 and next_urls[0] == url:
                            next_urls = next_urls[1:]
                            random.shuffle(next_urls)
                            next_urls.insert(0, url)
                        else:
                            random.shuffle(next_urls)
                    bundle.current_urls = OrderedDict.fromkeys(next_urls).keys()
                    
                    if bundles:
                        self.mq.put(bundles)
                    if hasattr(self.opener, 'close'):
                        self.opener.close()
                        
                    if self.stopped.wait(span):
                        break
                except UnitRetryFailed:
                    failed = True
                    break
        
        if len(bundle.current_urls) == 0 or failed:
            if self.settings.job.inc == True:
                self.mq.put_inc(bundle)
                
            if not failed:
                self._finish(bundle)
            else:
                return bundle
        else:
            return bundle
dataset/ETHPy150Open chineking/cola/cola/job/executor.py/BundleExecutor.execute/original