##// END OF EJS Templates
inotify: server: use a common 'pollable' interface for server & repowatcher...
Nicolas Dumazet -
r8610:8ef1f63e default
parent child Browse files
Show More
@@ -113,8 +113,33 b' def _explain_watch_limit(ui, repo, count'
113 113 raise util.Abort(_('cannot watch %s until inotify watch limit is raised')
114 114 % repo.root)
115 115
116 class repowatcher(object):
116 class pollable(object):
117 """
118 Interface to support polling.
119 The file descriptor returned by fileno() is registered to a polling
120 object.
121 Usage:
122 Every tick, check if an event has happened since the last tick:
123 * If yes, call handle_events
124 * If no, call handle_timeout
125 """
117 126 poll_events = select.POLLIN
127 def fileno(self):
128 raise NotImplementedError
129
130 def handle_events(self, events):
131 raise NotImplementedError
132
133 def handle_timeout(self):
134 raise NotImplementedError
135
136 def shutdown(self):
137 raise NotImplementedError
138
139 class repowatcher(pollable):
140 """
141 Watches inotify events
142 """
118 143 statuskeys = 'almr!?'
119 144 mask = (
120 145 inotify.IN_ATTRIB |
@@ -540,7 +565,7 b' class repowatcher(object):'
540 565 self.ui.note(_('%s hooking back up with %d bytes readable\n') %
541 566 (self.event_time(), self.threshold.readable()))
542 567 self.read_events(0)
543 self.master.poll.register(self, select.POLLIN)
568 self.master.poll.register(self, self.poll_events)
544 569 self.registered = True
545 570
546 571 self.timeout = None
@@ -555,9 +580,10 b' class repowatcher(object):'
555 580 """
556 581 return sorted(tuple[0][len(self.wprefix):] for tuple in self.watcher)
557 582
558 class server(object):
559 poll_events = select.POLLIN
560
583 class server(pollable):
584 """
585 Listens for client queries on unix socket inotify.sock
586 """
561 587 def __init__(self, ui, repo, repowatcher, timeout):
562 588 self.ui = ui
563 589 self.repo = repo
General Comments 0
You need to be logged in to leave comments. Login now