From 00bb55edf6835b7ce8ab98b76dcc7d403a2c4ce2 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 11 May 2016 22:17:41 -0700 Subject: [PATCH] The need to wait for a given time is no longer valid in 3.2+ The condition interrupt but is fixed in 3.2 so we can avoid some of the legacy logic in that version (and eventually at some point we can just remove that code). Change-Id: I45a871a212bb06fb69c36405161a9e66601b0f0d --- oslo_messaging/_drivers/pool.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/oslo_messaging/_drivers/pool.py b/oslo_messaging/_drivers/pool.py index 699ce5c10..1af1e3145 100644 --- a/oslo_messaging/_drivers/pool.py +++ b/oslo_messaging/_drivers/pool.py @@ -15,6 +15,7 @@ import abc import collections +import sys import threading from oslo_log import log as logging @@ -24,6 +25,16 @@ from oslo_messaging._drivers import common LOG = logging.getLogger(__name__) +# TODO(harlowja): remove this when we no longer have to support 2.7 +if sys.version_info[0:2] < (3, 2): + def wait_condition(cond): + # FIXME(markmc): timeout needed to allow keyboard interrupt + # http://bugs.python.org/issue8844 + cond.wait(timeout=1) +else: + def wait_condition(cond): + cond.wait() + @six.add_metaclass(abc.ABCMeta) class Pool(object): @@ -67,9 +78,7 @@ class Pool(object): self._current_size += 1 break - # FIXME(markmc): timeout needed to allow keyboard interrupt - # http://bugs.python.org/issue8844 - self._cond.wait(timeout=1) + wait_condition(self._cond) # We've grabbed a slot and dropped the lock, now do the creation try: