inotify/inserve: implement --timeout-idle option (issue885) stable
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Wed, 17 Feb 2010 20:44:49 +0100
branchstable
changeset 10494 08064db9f005
parent 10493 283f3b413f19
child 10495 2c2d2f1354b4
inotify/inserve: implement --timeout-idle option (issue885) hg inserve was ignoring and miscomputing the --timeout-idle option (seconds vs. minutes). Thanks to Jesse Glick for the bugreport and the initial patch.
hgext/inotify/linuxserver.py
hgext/inotify/server.py
--- a/hgext/inotify/linuxserver.py	Wed Feb 17 20:30:57 2010 +0100
+++ b/hgext/inotify/linuxserver.py	Wed Feb 17 20:44:49 2010 +0100
@@ -397,7 +397,7 @@
         self.register(timeout=timeout)
 
     def handle_timeout(self):
-        pass
+        raise server.TimeoutException
 
     def handle_pollevents(self, events):
         for e in events:
--- a/hgext/inotify/server.py	Wed Feb 17 20:30:57 2010 +0100
+++ b/hgext/inotify/server.py	Wed Feb 17 20:44:49 2010 +0100
@@ -19,6 +19,8 @@
 
 class AlreadyStartedException(Exception):
     pass
+class TimeoutException(Exception):
+    pass
 
 def join(a, b):
     if a:
@@ -444,9 +446,11 @@
 master = _server.master
 
 def start(ui, dirstate, root, opts):
-    timeout = opts.get('timeout')
+    timeout = opts.get('idle_timeout')
     if timeout:
-        timeout = float(timeout) * 1e3
+        timeout = float(timeout) * 60000
+    else:
+        timeout = None
 
     class service(object):
         def init(self):
@@ -457,7 +461,10 @@
 
         def run(self):
             try:
-                self.master.run()
+                try:
+                    self.master.run()
+                except TimeoutException:
+                    pass
             finally:
                 self.master.shutdown()