code: def close(self):
          
          if self._closed:
              return defer.succeed(None)
  
          def ok(_):
              self._closed = True
          return self.__flush().addCallback(ok)
docs: Flush the file and close it.
  
          A closed file cannot be written any more. Calling
          :meth:`close` more than once is allowed.