diff -r 4b96c153c113 -r 8127c0f4223d pvl/syslog/syslog.py --- a/pvl/syslog/syslog.py Sun Jan 13 00:23:34 2013 +0200 +++ b/pvl/syslog/syslog.py Sun Jan 13 00:25:01 2013 +0200 @@ -34,22 +34,27 @@ """ return self.filter(self.parser(self.source)) + + def fileno (self) : + return self.source.fileno() - def poll (self, poll=None) : + def poll (self, poll=None, reading=(), writing=()) : """ Poll our source for input, with given polling behaviour: True - select() on source False - peek on source float - timeout in seconds - - Returns True if we have input waiting, False on timeout with no input. None on indeterminate. + + Returns None on unknown, empty sequence on timeout, list of readables on select. """ + + # from __init__ + if poll is None : + poll = self._poll - reading = writing = () - if poll is True : timeout = None # block - reading += (self.source, ) # file-like object with fileno() + reading += (self, ) # source.fileno() elif not poll : timeout = 0.0 # do not block @@ -57,17 +62,20 @@ else : timeout = float(poll) - log.debug("%s", timeout) + log.debug("%s (%s)", reading, timeout) # select readable, writeable, ex = select.select(reading, writing, [], timeout) + + log.debug("select: %s", readable) if readable : - return True + return readable elif reading : # timeout - return False + # XXX: this is the same as readable + return () else : # unknown @@ -83,9 +91,6 @@ TODO: SIGINT -> finish iteration and return? """ - if poll is None : - poll = self._poll - # mainloop while True : # pull in messages