class_docstr: Container for multiple `Scene` objects.
class_docstr_tok: ["Container","for","multiple","`","Scene","`","objects","."]
docstr: Distribute save_datasets across a cluster.
code: def _distribute_save_datasets(
      self, scenes_iter, client, batch_size=1, **kwargs
  ):
      """Distribute save_datasets across a cluster."""
  
      def load_data(q):
          idx = 0
          while True:
              future_list = q.get()
              if future_list is None:
                  break
  
              # save_datasets shouldn't be returning anything
              for future in future_list:
                  future.result()
                  log.info("Finished saving %d scenes", idx)
                  idx += 1
              q.task_done()
  
      input_q = Queue(batch_size if batch_size is not None else 1)
      # set threads to daemon so they are killed if error is raised from main thread
      load_thread = Thread(
          target=load_data, args=(input_q,), daemon=True
      )
      load_thread.start()
  
      for scene in scenes_iter:
          delayeds = scene.save_datasets(compute=False, **kwargs)
          sources, targets, delayeds = split_results(delayeds)
          if len(sources) > 0:
              # TODO Make this work for (source, target) datasets
              # given a target, source combination
              raise NotImplementedError(
                  "Distributed save_datasets does not support writers "
                  "that return (source, target) combinations at this time. Use "
                  "the non-distributed save_datasets instead."
              )
          future = client.compute(delayeds)
          input_q.put(future)
      input_q.put(None)
  
      log.debug("Waiting for child thread to get saved results...")
      load_thread.join()
      log.debug("Child thread died successfully")
  
imports: from __future__ import annotations
  import copy
  import logging
  import warnings
  from queue import Queue
  from threading import Thread
  from typing import Callable, Collection, Mapping
  import dask.array
  import numpy
  import xarray
  from satpy.dataset import DataID
  from satpy.scene import Scene
  from satpy.writers import get_enhanced_image, split_results
label_desc: Use image node_id 18 for calling the MultiScene obj's underlying member method code with example usage: obj._distribute_save_datasets(scenes_iter, client, batch_size) without return types