'Block an event handler while waiting for a stanza to arrive.
Be aware that this will impact performance if called from a
non-threaded event handler.
Will return either the received stanza, or ``False`` if the
waiter timed out.
:param int timeout: The number of seconds to wait for the stanza
to arrive. Defaults to the the stream\'s
:class:`~sleekxmpp.xmlstream.xmlstream.XMLStream.response_timeout`
value.'

def wait(self, timeout=None):

    if (timeout is None):
        timeout = self.stream().response_timeout
    elapsed_time = 0
    stanza = False
    while ((elapsed_time < timeout) and (not self.stream().stop.is_set())):
        try:
            stanza = self._payload.get(True, 1)
            break
        except QueueEmpty:
            elapsed_time += 1
            if (elapsed_time >= timeout):
                log.warning('Timed    out    waiting    for    %s', self.name)
    self.stream().remove_handler(self.name)
    return stanza
