Mar-31-2021, 08:39 PM
(Mar-31-2021, 08:23 PM)deanhystad Wrote: You flip back and forth from looking at the front and the rear of the queue. That is why lastt appears to go backwards. The first time you print was after doing appending things to the queue:
if self.phys==0 or len(self.physqueue)<=self.phys: self.physqueue.append([tq, q]) self.lastt=tqThis sets lastt to the most recent time. However, if the if statement evaluates to False, the lasttt was updated by this code in __next__
td, cdata = self.dataqueue.pop(0) self.updateqmem(td) self.lastt=tdThis updates lasttt to the oldest item in dataqueue.
Your code is really hard to understand. Using better variable names would go a long way to improving readability; lasttt, tM, clinkdt, tq, qb? These would be ok if there was a description anywhere that says what they represent, as is I am left guessing. At the very minimum you should describe each of the arguments passed to inportProp.__init__ along with a short description of what inportProp is/does.
There is an algorithmic problem that I am always walking around...
I gave an explanation in the code for definitions