<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connectionLost(self, reason):
 """ Called when the response body has been completely delivered. @param reason: Either a twisted.web.client.ResponseDone exception or a twisted.web.http.PotentialDataLoss exception. """

        self.remaining.reset()

        try:
            result = json.load(self.remaining)
        except Exception, e:
            self.finished.errback(e)
            return

        returnValue = result
        if self.heartbeater:
            self.heartbeater.nextToken = result['token']
            returnValue = (result, self.heartbeater)

        self.finished.callback(returnValue)