Time.sleep: stop appending item to the list if time is early - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Time.sleep: stop appending item to the list if time is early (/thread-33286.html) |
Time.sleep: stop appending item to the list if time is early - quest - Apr-13-2021 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 |