docstr: Stop resources for all LightningWorks in this app.
  
  The Works are stopped rather than deleted so that they can be inspected for debugging.
docstr_tok: ["Stop","resources","for","all","LightningWorks","in","this","app",".","The","Works","are","stopped","rather","than","deleted","so","that","they","can","be","inspected","for","debugging","."]
code: def stop_all_works(self, works: List[LightningWork]) -> None:
      """Stop resources for all LightningWorks in this app.
  
      The Works are stopped rather than deleted so that they can be inspected for debugging.
  
      """
      cloud_works = self._get_cloud_work_specs(self.client)
  
      for cloud_work in cloud_works:
          self._stop_work(cloud_work)
  
      def all_works_stopped(
          works: List[Externalv1Lightningwork],
      ) -> bool:
          for work in works:
              # deleted work won't be in the request hence only checking for stopped & failed
              if work.status.phase not in (
                  V1LightningworkState.STOPPED,
                  V1LightningworkState.FAILED,
              ):
                  return False
          return True
  
      t0 = time()
      while not all_works_stopped(
          self._get_cloud_work_specs(self.client)
      ):
          # Wait a little..
          print("Waiting for works to stop...")
          sleep(3)
  
          # Break if we reached timeout.
          if time() - t0 > LIGHTNING_STOP_TIMEOUT:
              break
  
imports: import inspect
  import json
  import logging
  import os
  import random
  import string
  import urllib
  from time import monotonic, sleep, time
  from typing import List, Optional
  from lightning_cloud.openapi import AppinstancesIdBody, Externalv1LightningappInstance, Externalv1Lightningwork, V1BuildSpec, V1Drive, V1DriveSpec, V1DriveStatus, V1DriveType, V1Flowserver, V1LightningappInstanceState, V1LightningappRestartPolicy, V1LightningworkClusterDriver, V1LightningworkDrives, V1LightningworkSpec, V1LightningworkState, V1ListLightningworkResponse, V1Metadata, V1NetworkConfig, V1PackageManager, V1PythonDependencyInfo, V1SourceType, V1UserRequestedComputeConfig
  from lightning_cloud.openapi.rest import ApiException
  from lightning.app.core import LightningApp, LightningWork
  from lightning.app.core.queues import QueuingSystem
  from lightning.app.runners.backends.backend import Backend
  from lightning.app.storage import Drive, Mount
  from lightning.app.utilities.enum import WorkStageStatus, WorkStopReasons, make_status
  from lightning.app.utilities.exceptions import LightningPlatformException
  from lightning.app.utilities.network import LightningClient, _check_service_url_is_ready
  from lightning_cloud.openapi import SpecLightningappInstanceIdWorksBody, WorksIdBody
label_desc: Use image node_id 5 for calling the CloudBackend obj's underlying member method code with example usage: obj.stop_all_works(works) and returns: True, False