def wait_until_ready(self, name, polling_mechanism, timeout=None, polling_timeout=None):
"""Briefly waits until the socket is ready to be used, yields to other
greenlets until the socket becomes available.
returns the socket if available within the given timeout, or ``None``
:param socket_name: the socket name
:param polling_mechanism: either ``zmq.POLLIN`` or ``zmq.POLLOUT``
:param timeout: the timeout in seconds (accepts float) in which it
should wait for the socket to become available
(optional, defaults to ``core.DEFAULT_TIMEOUT_IN_SECONDS``)
:param polling_timeout: the polling timeout in miliseconds that will
be passed to ``zmq.Poller().poll()``.
(optional, defaults to ``core.DEFAULT_POLLING_TIMEOUT``)
"""
timeout = timeout is None and self.timeout or timeout
polling_timeout = polling_timeout is None and self.polling_timeout or polling_timeout
start = time.time()
current = start
while current - start < timeout:
self.engage(polling_timeout)
socket = self.ready(name, polling_mechanism, timeout=timeout)
current = time.time()
if socket:
return socket
评论列表
文章目录