class_docstr: Tests for horovod.runner.common.service.
code: def test_shutdown_during_request_basic(self):
      sleep = 2.0
      key = secret.make_secret_key()
      service = TestSleepService(key, duration=sleep)
      try:
          client = TestSleepClient(service.addresses(), key, attempts=1)
          start = time.time()
          threads = list(
              [
                  in_thread(
                      client.sleep,
                      name="request {}".format(i + 1),
                      daemon=False,
                  )
                  for i in range(5)
              ]
          )
          time.sleep(sleep / 2.0)
      finally:
          service.shutdown()
  
      duration = time.time() - start
      print("shutdown completed in {} seconds".format(duration))
      self.assertGreaterEqual(
          duration, sleep, "sleep requests should have been completed"
      )
      self.assertLess(
          duration,
          sleep + 1.0,
          "sleep requests should have been concurrent",
      )
  
      for thread in threads:
          thread.join(0.1)
          self.assertFalse(
              thread.is_alive(), "thread should have terminated by now"
          )
  
imports: import io
  import queue
  import threading
  import time
  import unittest
  import warnings
  import pytest
  from horovod.runner.common.service.task_service import BasicTaskClient, BasicTaskService
  from horovod.runner.common.util import network, secret
  from horovod.runner.util.threads import in_thread
  from horovod.runner.util.streams import Pipe
label_desc: Use image node_id 3 for calling the NetworkTests obj's underlying member method code with example usage: obj.test_shutdown_during_request_basic() without return types