Mercurial > hg
comparison hgext/inotify/server.py @ 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 |
comparison
equal
deleted
inserted
replaced
8608:228db070bfc4 | 8609:aeaa0bd9dc24 |
---|---|
498 def process_unmount(self, evt): | 498 def process_unmount(self, evt): |
499 self.ui.warn(_('filesystem containing %s was unmounted\n') % | 499 self.ui.warn(_('filesystem containing %s was unmounted\n') % |
500 evt.fullpath) | 500 evt.fullpath) |
501 sys.exit(0) | 501 sys.exit(0) |
502 | 502 |
503 def handle_pollevent(self): | 503 def handle_pollevents(self, events): |
504 if self.ui.debugflag: | 504 if self.ui.debugflag: |
505 self.ui.note(_('%s readable: %d bytes\n') % | 505 self.ui.note(_('%s readable: %d bytes\n') % |
506 (self.event_time(), self.threshold.readable())) | 506 (self.event_time(), self.threshold.readable())) |
507 if not self.threshold(): | 507 if not self.threshold(): |
508 if self.registered: | 508 if self.registered: |
638 ]] | 638 ]] |
639 | 639 |
640 def answer_dbug_query(self): | 640 def answer_dbug_query(self): |
641 return ['\0'.join(self.repowatcher.debug())] | 641 return ['\0'.join(self.repowatcher.debug())] |
642 | 642 |
643 def handle_pollevents(self, events): | |
644 for e in events: | |
645 self.handle_pollevent() | |
646 | |
643 def handle_pollevent(self): | 647 def handle_pollevent(self): |
644 sock, addr = self.sock.accept() | 648 sock, addr = self.sock.accept() |
645 | 649 |
646 cs = common.recvcs(sock) | 650 cs = common.recvcs(sock) |
647 version = ord(cs.read(1)) | 651 version = ord(cs.read(1)) |
726 except select.error, err: | 730 except select.error, err: |
727 if err[0] == errno.EINTR: | 731 if err[0] == errno.EINTR: |
728 continue | 732 continue |
729 raise | 733 raise |
730 if events: | 734 if events: |
735 by_fd = {} | |
731 for fd, event in events: | 736 for fd, event in events: |
732 self.table[fd].handle_pollevent() | 737 by_fd.setdefault(fd, []).append(event) |
738 | |
739 for fd, events in by_fd.iteritems(): | |
740 self.table[fd].handle_pollevents(events) | |
741 | |
733 elif timeobj: | 742 elif timeobj: |
734 timeobj.handle_timeout() | 743 timeobj.handle_timeout() |
735 | 744 |
736 def start(ui, repo): | 745 def start(ui, repo): |
737 def closefds(ignore): | 746 def closefds(ignore): |