Python Forum

Full Version: Time.sleep: stop appending item to the list if time is early
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have a timing problem. I want to stop appending item to the list, if time is early.
Here is my code lines:
self.tq is the arriving item time
self.lastt is the arrived item time
dataqueue is the list that I am put and send information after item is arrived
The condition is that: if self.otherport.lastt>self.lastt-self.delaytime: I can add the information to dataqueue
And if this condition is not valid, I want to stop to add information to dataqueue unless self.otherport.lastt>self.lastt-self.delaytime. How can I do that? I know in python we have time.sleep funtion but I could not stop to add info to the list
if self.tq <= self.lastt : 
            self.tq, self.arrivingqubit = next(self.inqubits)  
            print("we are here :)1")
         if len(self.dataqueue)==0:
            if self.otherport.lastt>self.lastt-self.delaytime:
               self.dataqueue.append((self.otherport.lastt+self.delaytime,self.fakequbit)) #here we have endless loop
               print("we are here :)2")
            #else: raise RuntimeError("Otherport is too old :(")
            else: #here I need to stop to adding item to list untill self.lastt>self.lastt-self.delaytime:
Thanks