Merge "Speedup the rabbit tests"

This commit is contained in:
Jenkins 2015-01-27 17:15:29 +00:00 committed by Gerrit Code Review
commit f211fb66c2
1 changed files with 10 additions and 6 deletions

View File

@ -515,9 +515,15 @@ class Connection(object):
{'hostname': self.connection.hostname, {'hostname': self.connection.hostname,
'port': self.connection.port}) 'port': self.connection.port})
# NOTE(sileht):
# value choosen according the best practice from kombu:
# http://kombu.readthedocs.org/en/latest/reference/kombu.common.html#kombu.common.eventloop
self._poll_timeout = 1
if self._url.startswith('memory://'): if self._url.startswith('memory://'):
# Kludge to speed up tests. # Kludge to speed up tests.
self.connection.transport.polling_interval = 0.0 self.connection.transport.polling_interval = 0.0
self._poll_timeout = 0.05
# FIXME(markmc): use oslo sslutils when it is available as a library # FIXME(markmc): use oslo sslutils when it is available as a library
_SSL_PROTOCOLS = { _SSL_PROTOCOLS = {
@ -723,10 +729,8 @@ class Connection(object):
queues_tail.consume(nowait=False) queues_tail.consume(nowait=False)
self.do_consume = False self.do_consume = False
# NOTE(sileht): poll_timeout = (self._poll_timeout if timeout is None
# maximun value choosen according the best practice from kombu: else min(timeout, self._poll_timeout))
# http://kombu.readthedocs.org/en/latest/reference/kombu.common.html#kombu.common.eventloop
poll_timeout = 1 if timeout is None else min(timeout, 1)
while True: while True:
if self._consume_loop_stopped: if self._consume_loop_stopped:
self._consume_loop_stopped = False self._consume_loop_stopped = False
@ -735,8 +739,8 @@ class Connection(object):
try: try:
return self.connection.drain_events(timeout=poll_timeout) return self.connection.drain_events(timeout=poll_timeout)
except socket.timeout as exc: except socket.timeout as exc:
poll_timeout = timer.check_return(_raise_timeout, exc, poll_timeout = timer.check_return(
maximum=1) _raise_timeout, exc, maximum=self._poll_timeout)
for iteration in itertools.count(0): for iteration in itertools.count(0):
if limit and iteration >= limit: if limit and iteration >= limit: