'A safer way to sleep than calling time.sleep() directly that would
keep the adapter from ignoring frames sent from the broker. The
connection will "sleep" or block the number of seconds specified in
duration in small intervals.
:param float duration: The time to sleep in seconds'

def sleep(self, duration):

    assert (duration >= 0), duration
    deadline = (time.time() + duration)
    time_limit = duration
    while True:
        self.process_data_events(time_limit)
        time_limit = (deadline - time.time())
        if (time_limit <= 0):
            break
