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
This commit is contained in:
Zane Bitter 2018-11-21 14:28:02 -05:00
parent 6566ec5e4b
commit d555763f8f
1 changed files with 16 additions and 0 deletions

View File

@ -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")