code: def read_file(fh_, chunk_size=1048576):
      '''
      Generator that reads chunk_size bytes at a time from a file/filehandle and
      yields it.
      '''
      try:
          if chunk_size != int(chunk_size):
              raise ValueError
      except ValueError:
          raise ValueError('chunk_size must be an integer')
      try:
          while True:
              try:
                  chunk = fh_.read(chunk_size)
              except AttributeError:
                  # Open the file and re-attempt the read
                  fh_ = salt.utils.files.fopen(fh_, 'rb')  # pylint: disable=W8470
                  chunk = fh_.read(chunk_size)
              if not chunk:
                  break
              yield chunk
      finally:
          try:
              fh_.close()
          except AttributeError:
              pasf read_file(fh_, chunk_size=1048576):
      '''
      Generator that reads chunk_size bytes at a time from a file/filehandle and
      yields it.
      '''
      try:
          if chunk_size != int(chunk_size):
              raise ValueError
      except ValueError:
          raise ValueError('chunk_size must be an integer')
      try:
          while True:
              try:
                  chunk = fh_.read(chunk_size)
              except AttributeError:
                  # Open the file and re-attempt the read
                  fh_ = salt.utils.files.fopen(fh_, 'rb')  # pylint: disable=W8470
                  chunk = fh_.read(chunk_size)
              if not chunk:
                  break
              yield chunk
      finally:
          try:
              fh_.close()
          except AttributeError:
              pass
docs: Generator that reads chunk_size bytes at a time from a file/filehandle and
      yields it.