ferleal / pytuio

Automatically exported from code.google.com/p/pytuio
MIT License
0 stars 0 forks source link

update timeout suggestion #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I have a small suggestion about a very minor issue. The update method of the 
Tracking will never blocked so if we want to track continually, as I think most 
people need, we don't have any choice to make an infinite loop uselessly 
costly. I think it could be interesting to be able to say if we prefer to wait 
or no (and how many time). Here is what I changed :

    def update(self, waitTimeout=None):
        """
        Tells the connection manager to receive the next 1024 byte of messages
        to analyze.
        """
        oldtimeout=self.socket.gettimeout()
        timeoutChanged=oldtimeout!=waitTimeout
        if timeoutChanged:
            self.socket.settimeout(waitTimeout)
            timeoutChanged=True
        try:
            self.manager.handle(self.socket.recv(1024))
            return self.refreshed()
        except socket.error:
            return False
        finally:
            if timeoutChanged:
                self.socket.settimeout(oldtimeout)

Best regards,

Quentin Roy

Original issue reported on code.google.com by roy...@gmail.com on 11 Jun 2010 at 9:49