Permalink
Browse files

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...
1 parent 9d13ce5 commit e09b09153131823b12bfca6824ee90c1d361a011 @tsuna tsuna committed with tsuna Jul 1, 2012
Showing with 4 additions and 11 deletions.
  1. +4 −11 tcollector.py
View
@@ -997,18 +997,11 @@ def spawn_collector(col):
col.proc = subprocess.Popen(col.filename, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except OSError, e:
- if e.errno == 13:
- LOG.error('failed to spawn collector %s: permission denied' %
- col.filename)
- return
- elif e.errno == 2:
- LOG.error('failed to spawn collector %s: no such file or directory' %
- col.filename)
- else:
- raise
- # the following line needs to move below this line because it is used in
+ LOG.error('Failed to spawn collector %s: %s' % (col.filename, e))
+ return
+ # The following line needs to move below this line because it is used in
# other logic and it makes no sense to update the last spawn time if the
- # collector didn't actually spam
+ # collector didn't actually start.
col.lastspawn = int(time.time())
set_nonblocking(col.proc.stdout.fileno())
set_nonblocking(col.proc.stderr.fileno())

0 comments on commit e09b091

Please sign in to comment.