mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	queue_processors: Fix UnboundLocalError in QueueProcessingWorker.
consume_time_seconds wasn't properly defined at the beginning, so when a BaseException that isn't a subclass of Exception is thrown, the finally: block could be entered with it still undefined.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							4dc83a139c
						
					
				
				
					commit
					a7039c815e
				
			@@ -212,14 +212,14 @@ class QueueProcessingWorker(ABC):
 | 
			
		||||
 | 
			
		||||
    def do_consume(self, consume_func: Callable[[List[Dict[str, Any]]], None],
 | 
			
		||||
                   events: List[Dict[str, Any]]) -> None:
 | 
			
		||||
        consume_time_seconds: Optional[float] = None
 | 
			
		||||
        try:
 | 
			
		||||
            time_start = time.time()
 | 
			
		||||
            consume_func(events)
 | 
			
		||||
            consume_time_seconds: Optional[float] = time.time() - time_start
 | 
			
		||||
            consume_time_seconds = time.time() - time_start
 | 
			
		||||
            self.consumed_since_last_emptied += len(events)
 | 
			
		||||
        except Exception:
 | 
			
		||||
            self._handle_consume_exception(events)
 | 
			
		||||
            consume_time_seconds = None
 | 
			
		||||
        finally:
 | 
			
		||||
            flush_per_request_caches()
 | 
			
		||||
            reset_queries()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user