]> git.llucax.com Git - software/pymin.git/blobdiff - pymindaemon.py
Add a missing handler decorator to PyminDaemon test.
[software/pymin.git] / pymindaemon.py
index b7c64e4104bbe8a2376ae315910a8e7df5c4f055..1ddef6c5d2bff19927580e11ceeb368368346a3d 100644 (file)
@@ -47,7 +47,7 @@ class PyminDaemon(EventLoop):
         # Signal handling
         def quit(signum, frame):
             print "Shuting down ..."
-            loop.stop() # tell main event loop to stop
+            self.stop() # tell main event loop to stop
         def reload_config(signum, frame):
             print "Reloading configuration..."
             # TODO iterate handlers list propagating reload action
@@ -58,7 +58,12 @@ class PyminDaemon(EventLoop):
     def handle(self):
         r"handle() -> None :: Handle incoming events using the dispatcher."
         (msg, addr) = self.file.recvfrom(65535)
-        self.dispatcher.dispatch(msg)
+        result = self.dispatcher.dispatch(msg)
+        if result is None:
+            msg = 'OK 0'
+        else:
+            msg = 'OK %d\n%s' % (len(str(result)), result)
+        self.file.sendto(msg, addr)
         #try:
         #    d.dispatch(msg)
         #except dis.BadRouteError, inst:
@@ -75,6 +80,7 @@ class PyminDaemon(EventLoop):
 
 if __name__ == '__main__':
 
+    @handler
     def test_handler(*args):
         print 'test:', args