docstr: Return an iterator that yields bytes whose total size is
  `chunk_size` from the beginning of the write buffer.
docstr_tok: ["Return","an","iterator","that","yields","bytes","whose","total","size","is","`","chunk_size","`","from","the","beginning","of","the","write","buffer","."]
code: def chunks(self, chunk_size: int) -> Iterator[Iterator[bytes]]:
      """Return an iterator that yields bytes whose total size is
      `chunk_size` from the beginning of the write buffer."""
      assert not self._iterating
  
      def _chunks_iterator() -> Iterator[bytes]:
          remaining = chunk_size
          i = 0
          while remaining > 0:
              b = self._buffers[i]
              n = len(b)
              if n <= remaining:
                  yield b
                  remaining -= n
                  i += 1
              else:
                  yield b[:remaining]
                  break
  
      self._iterating = True
      yield _chunks_iterator()
      self._iterating = False
  
file_path: hail/hail/python/hailtop/aiotools/utils.py
imports: from typing import Deque, TypeVar, AsyncIterator, Iterator
  import collections
  from contextlib import contextmanager
  import asyncio
label_desc: Use image node_id 6 for calling the WriteBuffer obj's underlying member method code with example usage: obj.chunks(chunk_size) without return types