def wait_until_idle(self):
        """Block the calling thread until the work queue is (temporarily) empty.

        See the detailed discussion under defer_until_idle() for restrictions
        and expected use cases for this method.

        This routine will block the calling thread.
        """

        done = threading.Event()

        def _callback():
            done.set()

        self.defer_until_idle(_callback)
        done.wait()
Block the calling thread until the work queue is (temporarily) empty.

        See the detailed discussion under defer_until_idle() for restrictions
        and expected use cases for this method.

        This routine will block the calling thread.