Refactor GPIOQueue.fill()

squash the two while loops down into one
This commit is contained in:
Andrew Scheller
2016-09-21 00:09:41 +01:00
parent f607a27c79
commit ac37ec26bc

View File

@@ -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!