<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -8,6 +8,20 @@ from disconode.disco_worker import JOB_ROOT, OOB_FILE, PARAMS_FILE, CHDIR_PATH
 from disco.netstring import decode_netstring_fd
 from disco import util, comm
 
+
+def run(method, mode, part, jobpack):
+        if int(jobpack['profile']):
+                try:
+                        import cProfile as prof
+                except:
+                        import profile as prof
+
+                key = &quot;profile-%s-%s&quot; % (mode, part)
+                prof.run(&quot;method(m)&quot;, OOB_FILE % key)
+                dw.put(key, None) 
+        else:
+                method(jobpack)
+
 if __name__ == &quot;__main__&quot;:
         if len(sys.argv) &lt; 7:
                 util.err(&quot;Invalid command line. &quot;\
@@ -21,9 +35,14 @@ if __name__ == &quot;__main__&quot;:
         mode = sys.argv[1]
         name = sys.argv[2]
         master_url = sys.argv[4]
+        part = sys.argv[5]
 
-        ensure_path(OOB_FILE % &quot;&quot;, False)
-        os.chdir(CHDIR_PATH)
+        try: 
+                ensure_path(OOB_FILE % &quot;&quot;, False)
+                os.chdir(CHDIR_PATH)
+        except Exception, e:
+                util.data_err(&quot;Failed to initialize worker directories &quot;\
+                                &quot;(disk full?)&quot;, &quot;&quot;)
         
         try:
                 if util.resultfs_enabled:
@@ -55,17 +74,12 @@ if __name__ == &quot;__main__&quot;:
         method = getattr(dw, 'op_' + mode, None)
         if method is None:
                 util.err(&quot;Invalid operation: %s&quot; % mode)
-        
-        if int(m['profile']):
-                try:
-                        import cProfile as prof
-                except:
-                        import profile as prof
 
-                key = &quot;profile-%s-%s&quot; % (mode, sys.argv[5])
-                prof.run(&quot;method(m)&quot;, OOB_FILE % key)
-                dw.put(key, None) 
-        else:
-                method(m)
+        try:
+                run(method, mode, part, m)
+        except comm.CommException, x:
+                util.data_err(&quot;HTTP error: %s&quot; % x)
+        except IOError, x:
+                util.data_err(&quot;IO error: %s&quot; % x)
         
         util.msg(&quot;Worker done&quot;, &quot;END&quot;)</diff>
      <filename>node/disco-worker</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7885a37f0e80124ab737f6dd0e172df73a2f2d74</id>
    </parent>
  </parents>
  <author>
    <name>Ville Tuulos</name>
    <email>tuulos@dxfront.(none)</email>
  </author>
  <url>http://github.com/tuulos/disco/commit/f1d4a127c991eef574bac164f10fadf7b6981298</url>
  <id>f1d4a127c991eef574bac164f10fadf7b6981298</id>
  <committed-date>2009-09-09T16:46:00-07:00</committed-date>
  <authored-date>2009-09-09T16:46:00-07:00</authored-date>
  <message>All IOErrors and CommExceptions in disco-worker now raise data_err(), so they shouldn't crash the job anymore</message>
  <tree>a4c9de1e538d91bcbcda0038b37b890e0c69ec41</tree>
  <committer>
    <name>Ville Tuulos</name>
    <email>tuulos@dxfront.(none)</email>
  </committer>
</commit>
