code: def write(self, value):
          
  
          if self.capacity > 0 and self.strategy == 0:
              len_value = len(value)
              if len_value >= self.capacity:
                  needs_new_strategy = True
              else:
                  self.seek(0, 2)  # find end of file
                  needs_new_strategy = \
                      (self.tell() + len_value) >= self.capacity
              if needs_new_strategy:
                  self.makeTempFile()
  
          if not isinstance(value, six.binary_type):
              value = value.encode('utf-8')
  
          self._delegate.write(value)
docs: If capacity != -1 and length of file > capacity it is time to switch