def error(self, err=None):
        """Update the circuit breaker with an error event."""
        if self.state == 'half-open':
            self.test_fail_count = min(self.test_fail_count + 1, 16)
        self.errors.append(self.clock())
        if len(self.errors) > self.maxfail:
            time = self.clock() - self.errors.pop(0)
            if time < self.time_unit:
                if time == 0:
                    time = 0.0001
                self.log.debug('error rate: %f errors per second' % (
                        float(self.maxfail) / time))
                self.open(err)
Update the circuit breaker with an error event.