code: def _handle_command_buffer(self):
          
          if self._should_write_to_command_buffer:
              self._write_to_command_buffer(self._commands.to_json())
              self._should_write_to_command_buffer = False
              self._commands.clear()
docs: Checks if we should write to the command buffer, writes all of the queued commands to the buffer, and then
          clears the contents of the self._commands list