mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Refactor GPIOQueue.fill()
squash the two while loops down into one
This commit is contained in:
		@@ -493,15 +493,11 @@ class GPIOQueue(GPIOThread):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def fill(self):
 | 
					    def fill(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            while (not self.stopping.wait(self.sample_wait) and
 | 
					 | 
				
			||||||
                    len(self.queue) < self.queue.maxlen):
 | 
					 | 
				
			||||||
                self.queue.append(self.parent._read())
 | 
					 | 
				
			||||||
                if self.partial and isinstance(self.parent, EventsMixin):
 | 
					 | 
				
			||||||
                    self.parent._fire_events()
 | 
					 | 
				
			||||||
            self.full.set()
 | 
					 | 
				
			||||||
            while not self.stopping.wait(self.sample_wait):
 | 
					            while not self.stopping.wait(self.sample_wait):
 | 
				
			||||||
                self.queue.append(self.parent._read())
 | 
					                self.queue.append(self.parent._read())
 | 
				
			||||||
                if isinstance(self.parent, EventsMixin):
 | 
					                if not self.full.is_set() and len(self.queue) >= self.queue.maxlen:
 | 
				
			||||||
 | 
					                    self.full.set()
 | 
				
			||||||
 | 
					                if (self.partial or self.full.is_set()) and isinstance(self.parent, EventsMixin):
 | 
				
			||||||
                    self.parent._fire_events()
 | 
					                    self.parent._fire_events()
 | 
				
			||||||
        except ReferenceError:
 | 
					        except ReferenceError:
 | 
				
			||||||
            # Parent is dead; time to die!
 | 
					            # Parent is dead; time to die!
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user