[Neo-report] r2139 gregory - /trunk/neo/master/app.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jun 7 14:34:17 CEST 2010


Author: gregory
Date: Mon Jun  7 14:34:16 2010
New Revision: 2139

Log:
Rewrite shutdown() a bit.

- Merge sys.exit()
- Remove exit message
- Move out of loop the code that should run once
- Add an XXX

Modified:
    trunk/neo/master/app.py

Modified: trunk/neo/master/app.py
==============================================================================
--- trunk/neo/master/app.py [iso-8859-1] (original)
+++ trunk/neo/master/app.py [iso-8859-1] Mon Jun  7 14:34:16 2010
@@ -493,21 +493,22 @@
             node.getConnection().setHandler(handler)
 
         # wait for all transaction to be finished
-        while True:
+        while self.tm.hasPending():
             self.em.poll(1)
-            if self.tm.hasPending():
-                continue
-            if self.cluster_state == ClusterStates.RUNNING:
-                sys.exit("Application has been asked to shut down")
+
+        if self.cluster_state != ClusterStates.RUNNING:
             logging.info("asking all nodes to shutdown")
+            # This code sends packets but never polls, so they never reach
+            # network.
             for node in self.nm.getIdentifiedList():
                 notification = Packets.NotifyNodeInformation([node.asTuple()])
                 if node.isClient():
                     node.notify(notification)
                 elif node.isStorage() or node.isMaster():
                     node.notify(notification)
-            # then shutdown
-            sys.exit("Cluster has been asked to shut down")
+
+        # then shutdown
+        sys.exit()
 
     def identifyStorageNode(self, uuid, node):
         state = NodeStates.RUNNING





More information about the Neo-report mailing list