Skip to content
This repository
Browse code

Handle all OSError when spawning a collector.

Recently ran into `OSError: [Errno 26] Text file busy' while
live-editing a collector, which made the main thread die.  :(

Change-Id: Iec15a6d2c89977e947168bff749bcd00ddb9ef06
Reviewed-on: http://review.stumble.net/14309
Reviewed-by: Dave Barr <barr@stumbleupon.com>
Reviewed-by: Benoit Sigoure <tsuna@stumbleupon.com>
Tested-by: Benoit Sigoure <tsuna@stumbleupon.com>
  • Loading branch information...
commit e09b09153131823b12bfca6824ee90c1d361a011 1 parent 9d13ce5
Benoit Sigoure authored June 30, 2012 tsuna committed July 01, 2012

Showing 1 changed file with 4 additions and 11 deletions. Show diff stats Hide diff stats

  1. 15  tcollector.py
15  tcollector.py
@@ -997,18 +997,11 @@ def spawn_collector(col):
997 997
         col.proc = subprocess.Popen(col.filename, stdout=subprocess.PIPE,
998 998
                                 stderr=subprocess.PIPE)
999 999
     except OSError, e:
1000  
-        if e.errno == 13:
1001  
-            LOG.error('failed to spawn collector %s: permission denied' %
1002  
-                      col.filename)
1003  
-            return
1004  
-        elif e.errno == 2:
1005  
-            LOG.error('failed to spawn collector %s: no such file or directory' %
1006  
-                      col.filename)
1007  
-        else:
1008  
-            raise
1009  
-    # the following line needs to move below this line because it is used in
  1000
+        LOG.error('Failed to spawn collector %s: %s' % (col.filename, e))
  1001
+        return
  1002
+    # The following line needs to move below this line because it is used in
1010 1003
     # other logic and it makes no sense to update the last spawn time if the
1011  
-    # collector didn't actually spam
  1004
+    # collector didn't actually start.
1012 1005
     col.lastspawn = int(time.time())
1013 1006
     set_nonblocking(col.proc.stdout.fileno())
1014 1007
     set_nonblocking(col.proc.stderr.fileno())

0 notes on commit e09b091

Please sign in to comment.
Something went wrong with that request. Please try again.