Mercurial > hg-stable
changeset 8609:aeaa0bd9dc24
inotify: process all inotify events in one batch
When several inotify events happen, we don't have to process each event
separately, calling everytime repowatcher.read_events() to fetch events from
the underlying watcher: it is sufficient to call once read_events, to fetch
all the events from the watcher.
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Thu, 21 May 2009 19:26:15 +0900 |
parents | 228db070bfc4 |
children | 8ef1f63e554c |
files | hgext/inotify/server.py |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/inotify/server.py Thu May 21 19:22:29 2009 +0900 +++ b/hgext/inotify/server.py Thu May 21 19:26:15 2009 +0900 @@ -500,7 +500,7 @@ evt.fullpath) sys.exit(0) - def handle_pollevent(self): + def handle_pollevents(self, events): if self.ui.debugflag: self.ui.note(_('%s readable: %d bytes\n') % (self.event_time(), self.threshold.readable())) @@ -640,6 +640,10 @@ def answer_dbug_query(self): return ['\0'.join(self.repowatcher.debug())] + def handle_pollevents(self, events): + for e in events: + self.handle_pollevent() + def handle_pollevent(self): sock, addr = self.sock.accept() @@ -728,8 +732,13 @@ continue raise if events: + by_fd = {} for fd, event in events: - self.table[fd].handle_pollevent() + by_fd.setdefault(fd, []).append(event) + + for fd, events in by_fd.iteritems(): + self.table[fd].handle_pollevents(events) + elif timeobj: timeobj.handle_timeout()