From d555763f8f2fd56ae3e11990d095a52097e452f4 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Wed, 21 Nov 2018 14:28:02 -0500 Subject: [PATCH] Maintain private interface for loopingcall._ThreadingEvent A previous patch replaced the _Event() function and _ThreadingEvent() class in oslo_service.loopingcall with a single _Event() class. However, some consumers of oslo_service (including Nova) were relying on the private interface to mock methods during unit testing, which prevents them updating to the latest version of oslo.service. Make '_ThreadingEvent' a reference to the _Event class, and add deprecated methods compatible with the previous interface, so that the private interface does not change. This is a stable-only change, because on master we now require consumers to use oslo_service.fixture.SleepFixture rather than rely on the private interface. Change-Id: I37b38c8e1382cdf28a533dfcfc017d238c3f2684 Related-Bug: #1798774 --- oslo_service/loopingcall.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/oslo_service/loopingcall.py b/oslo_service/loopingcall.py index dc958040..400d32aa 100644 --- a/oslo_service/loopingcall.py +++ b/oslo_service/loopingcall.py @@ -18,6 +18,7 @@ import random import sys import time +import warnings from eventlet import event from eventlet import greenthread @@ -101,6 +102,21 @@ class _Event(object): self._event.wait() return self.is_set() + def is_running(self): + warnings.warn("This private API is removed in the next minor release.", + DeprecationWarning) + return not self.is_set() + + def done(self): + warnings.warn("This private API is removed in the next minor release.", + DeprecationWarning) + return self.set() + + +# For backwards compatibility with tests in consumers that were relying on the +# private interface. +_ThreadingEvent = _Event + class LoopingCallBase(object): _KIND = _("Unknown looping call")