[cig-commits] r15681 - in cs/pythia/trunk/pyre: applications services

leif at geodynamics.org leif at geodynamics.org
Fri Sep 18 21:17:07 PDT 2009


Author: leif
Date: 2009-09-18 21:17:06 -0700 (Fri, 18 Sep 2009)
New Revision: 15681

Modified:
   cs/pythia/trunk/pyre/applications/Daemon.py
   cs/pythia/trunk/pyre/services/Pickler.py
Log:
In pyre.services.Pickler.receive(), specify a buffer size of zero when
calling socket.makefile() -- as is done in Pickler.send() --
otherwise, data may be lost.

In pyre.applications.Daemon(), trap exceptions and log them using
journal.


Modified: cs/pythia/trunk/pyre/applications/Daemon.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Daemon.py	2009-09-19 00:05:02 UTC (rev 15680)
+++ cs/pythia/trunk/pyre/applications/Daemon.py	2009-09-19 04:17:06 UTC (rev 15681)
@@ -65,10 +65,10 @@
 
     def daemon(self, pid, spawn=True):
         import os
+        import journal
 
         # change the working directory to my home directory
         if not os.path.exists(self.home):
-            import journal
             journal.error(self.name).log("directory %r does not exist" % self.home)
             self.home = '/tmp'
 
@@ -87,7 +87,17 @@
             os.close(0)
         
         # launch the application
-        self.main(*self.args, **self.kwds)
+        if spawn:
+            try:
+                self.main(*self.args, **self.kwds)
+            except KeyboardInterrupt:
+                journal.error(self.name).log("interrupt")
+            except Exception, e:
+                import traceback
+                journal.error(self.name).log("exception:\n%s" % traceback.format_exc())
+        else:
+            # debug mode
+            self.main(*self.args, **self.kwds)
 
         return
 

Modified: cs/pythia/trunk/pyre/services/Pickler.py
===================================================================
--- cs/pythia/trunk/pyre/services/Pickler.py	2009-09-19 00:05:02 UTC (rev 15680)
+++ cs/pythia/trunk/pyre/services/Pickler.py	2009-09-19 04:17:06 UTC (rev 15681)
@@ -55,7 +55,7 @@
 
 
     def receive(self, socket):
-        stream = socket.makefile("rb")
+        stream = socket.makefile("rb", 0)
 
         try:
             request = pickle.load(stream)



More information about the CIG-COMMITS mailing list