code: def test_03_08_a_sad_moment(self):
      #
      # Run using the good pipeline, but change one of the URLs so
      # an exception is thrown.
      #
      self.awthread = self.AWThread(self.work_addr, self.zmq_context)
      self.awthread.start()
      self.set_work_socket()
      self.awthread.ex(
          self.awthread.aw.do_job,
          anareply.Work(
              image_set_numbers=[2, 3],
              worker_runs_post_group=False,
              wants_dictionary=False,
          ),
      )
      #
      # The worker should ask for the pipeline and preferences next.
      #
      req = self.awthread.recv(self.work_socket)
      self.assertIsInstance(req, anarequest.PipelinePreferences)
      self.assertEqual(req.analysis_id, self.analysis_id)
  
      input_dir = os.path.join(
          tests.core.modules.example_images_directory(),
          "ExampleSBSImages",
      )
      cellprofiler_core.preferences.set_default_image_directory(
          input_dir
      )
      preferences = {
          cellprofiler_core.preferences.DEFAULT_IMAGE_DIRECTORY: cellprofiler_core.preferences.config_read(
              cellprofiler_core.preferences.DEFAULT_IMAGE_DIRECTORY
          )
      }
  
      rep = cellprofiler_core.utilities.zmq.Reply(
          pipeline_blob=numpy.array(GOOD_PIPELINE),
          preferences=preferences,
      )
      req.reply(rep)
      #
      # The worker asks for the initial measurements.
      #
      req = self.awthread.recv(self.work_socket)
      self.assertIsInstance(req, anarequest.InitialMeasurements)
      self.assertEqual(req.analysis_id, self.analysis_id)
      m = get_measurements_for_good_pipeline(nimages=3)
      m[
          cellprofiler_core.constants.measurement.IMAGE,
          cellprofiler_core.modules.namesandtypes.M_IMAGE_SET,
          2,
      ] = numpy.zeros(100, numpy.uint8)
      try:
          req.reply(
              cellprofiler_core.utilities.zmq.Reply(
                  buf=m.file_contents()
              )
          )
      finally:
          m.close()
      #
      # Next, the worker asks for the shared dictionary
      #
      req = self.awthread.recv(self.work_socket)
      self.assertIsInstance(req, anarequest.SharedDictionary)
      shared_dictionaries = [
          {("foo%d" % i): "bar%d" % i}
          for i in range(1, NUM_MODULES + 1)
      ]
      rep = anareply.SharedDictionary(dictionaries=shared_dictionaries)
      req.reply(rep)
      #
      # The worker should choke somewhere in NamesAndTypes, but we
      # tell the worker to skip the rest of the imageset.
      #
      req = self.awthread.recv(self.work_socket)
      self.assertIsInstance(req, anarequest.ExceptionReport)
      req.reply(anareply.ExceptionPleaseDebug(disposition="Skip"))
      #
      # The worker should send ImageSetSuccess for image set 2 anyway.
      #
      req = self.awthread.recv(self.work_socket)
      self.assertIsInstance(req, anareply.ImageSetSuccess)
      self.assertEqual(req.image_set_number, 2)
      req.reply(anareply.Ack())
      #
      # And then it tells us about image set 3
      #
      req = self.awthread.recv(self.work_socket)
      self.assertIsInstance(req, anareply.ImageSetSuccess)
      self.assertEqual(req.image_set_number, 3)
      req.reply(anareply.Ack())
      #
      # The worker should then report the measurements for both 2 and 3
      #
      req = self.awthread.recv(self.work_socket)
      self.assertIsInstance(req, anarequest.MeasurementsReport)
      self.assertSequenceEqual(req.image_set_numbers, [2, 3])
      m = cellprofiler_core.utilities.measurement.load_measurements_from_buffer(
          req.buf
      )
  
      req.reply(anareply.Ack())
      self.awthread.ecute()
  
imports: import io
  import queue
  import time
  import os
  import pytest
  import pickle
  import tempfile
  import threading
  import traceback
  import unittest
  import uuid
  import zlib
  import numpy
  import zmq
  import cellprofiler_core.analysis
  import cellprofiler_core.analysis.reply
  import cellprofiler_core.constants.measurement
  import cellprofiler_core.constants.worker
  import cellprofiler_core.measurement
  import cellprofiler_core.module._identify
  import cellprofiler_core.modules.namesandtypes
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.utilities.image
  import cellprofiler_core.utilities.measurement
  import cellprofiler_core.utilities.pathname
  import cellprofiler_core.utilities.zmq
  import cellprofiler_core.worker
  import cellprofiler_core.analysis.request
  from cellprofiler_core.constants.modules.namesandtypes import M_IMAGE_SET_ZIP_DICTIONARY
  from cellprofiler_core.pipeline import ImageFile
  from cellprofiler_core.pipeline import ImagePlane
  import tests.core
  import tests.core.modules
label_desc: Use image node_id 18 for calling the TestAnalysisWorker obj's underlying member method code with example usage: obj.test_03_08_a_sad_moment() without return types