docstr: wait for the cluster to become idle, according to the everyone.
docstr_tok: ["wait","for","the","cluster","to","become","idle",",","according","to","the","everyone","."]
code: def _wait_for_idle(self):
      """wait for the cluster to become idle, according to the everyone."""
      rc = self.client
  
      # step 0. wait for local results
      # this should be sufficient 99% of the time.
      rc.wait(timeout=5)
  
      # step 1. wait for all requests to be noticed
      # timeout 5s, polling every 100ms
      msg_ids = set(rc.history)
      hub_hist = rc.hub_history()
      for i in range(50):
          if msg_ids.difference(hub_hist):
              time.sleep(0.1)
              hub_hist = rc.hub_history()
          else:
              break
  
      assert len(msg_ids.difference(hub_hist)) == 0
  
      # step 2. wait for all requests to be done
      # timeout 5s, polling every 100ms
      qs = rc.queue_status()
      for i in range(50):
          if qs["unassigned"] or any(
              qs[eid]["tasks"] + qs[eid]["queue"]
              for eid in qs
              if eid != "unassigned"
          ):
              time.sleep(0.1)
              qs = rc.queue_status()
          else:
              break
  
      # ensure Hub up to date:
      assert qs["unassigned"] == 0
      for eid in [eid for eid in qs if eid != "unassigned"]:
          assert qs[eid]["tasks"] == 0
          assert qs[eid]["queue"] == 0
  
imports: import os
  import signal
  import socket
  import sys
  import time
  import warnings
  from concurrent.futures import Future
  from datetime import datetime
  from threading import Thread
  from unittest import mock
  import pytest
  import tornado
  from IPython import get_ipython
  from ipyparallel import AsyncHubResult, DirectView, Reference, error
  from ipyparallel.client import client
  from ipyparallel.util import utc
  from .clienttest import ClusterTestCase, raises_remote, skip_without, wait
label_desc: Use image node_id 24 for calling the TestClient obj's underlying member method code with example usage: obj._wait_for_idle() without return types