On Fri, Apr 6, 2012 at 8:29 AM, Andrew Wu > --- urwid_bak/main_loop.py 2012-04-03 19:20:16.000000000 +0800 > +++ urwid/main_loop.py 2012-04-06 20:18:20.000000000 +0800 > @@ -186,8 +186,7 @@ > data = os.read(pipe_rd, PIPE_BUFFER_READ_SIZE) > rval = callback(data) > if rval is False: > - self.event_loop.remove_watch_file(watch_handle) > - os.close(pipe_rd) > + self.remove_watch_pipe(pipe_wr) > > watch_handle = self.event_loop.watch_file(pipe_rd, cb) > self._watch_pipes[pipe_wr] = (watch_handle, pipe_rd)
That does seem to make more sense. Now that I'm looking at it though I don't like the interface. As in your test code you need to add a comment on "return False" to understand what is actually going to happen. Using something like this might be an improvement: return "close pipe" There is also the problem of leaking fds. The write fd is not closed by remove_watch_pipe (as documented). Maybe an optional parameter to close both ends would help? Now it seems like there shouldn't be a special way to close a pipe with a handler's return value (getting too complicated) Thoughts? Ian _______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
