Skip to content

Commit

Permalink
Handle errors on master-side close in FileUpload
Browse files Browse the repository at this point in the history
A file isn't truly uploaded until the file on the master is closed, and
thus flushed.  Fixes #847
  • Loading branch information
Dustin J. Mitchell committed Oct 4, 2010
1 parent a050670 commit 4f3314d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions slave/buildslave/commands/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ def start(self):

d = defer.Deferred()
self._reactor.callLater(0, self._loop, d)
def _close(res):
# close the file
def _close_ok(res):
self.fp = None

# call close, but pass through any errors from _loop
return self.writer.callRemote("close")
def _close_err(f):
self.fp = None
# call remote's close(), but keep the existing failure
d1 = self.writer.callRemote("close")
d1.addErrback(log.err)
d1.addCallback(lambda ignored: res)
def eb(f2):
log.msg("ignoring error from remote close():")
log.err(f2)
d1.addErrback(eb)
d1.addBoth(lambda _ : f) # always return _loop failure
return d1
d.addBoth(_close)
d.addCallbacks(_close_ok, _close_err)
d.addBoth(self.finished)
return d

Expand Down Expand Up @@ -271,7 +275,7 @@ def start(self):
def _close(res):
# close the file, but pass through any errors from _loop
d1 = self.reader.callRemote('close')
d1.addErrback(log.err)
d1.addErrback(log.err) # ignore errors closing a reader file
d1.addCallback(lambda ignored: res)
return d1
d.addBoth(_close)
Expand Down

0 comments on commit 4f3314d

Please sign in to comment.