use make_weak_ref and resolve_ref from neutron-lib
The make_weak_ref and resolve_ref functions were rehomed into neutron-lib with https://review.openstack.org/#/c/557809/ This patch consumes them by removing the functions and using lib's version of them instead. NeutronLibImpact Change-Id: I41169ed0d93ea8caee530dcfc01a91271f02d538
This commit is contained in:
@@ -29,7 +29,6 @@ import sys
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
import weakref
|
||||
|
||||
import eventlet
|
||||
from eventlet.green import subprocess
|
||||
@@ -777,27 +776,6 @@ def get_related_rand_device_names(prefixes):
|
||||
max_length=n_const.DEVICE_NAME_MAX_LEN)
|
||||
|
||||
|
||||
try:
|
||||
# PY3
|
||||
weak_method = weakref.WeakMethod
|
||||
except AttributeError:
|
||||
# PY2
|
||||
import weakrefmethod
|
||||
weak_method = weakrefmethod.WeakMethod
|
||||
|
||||
|
||||
def make_weak_ref(f):
|
||||
"""Make a weak reference to a function accounting for bound methods."""
|
||||
return weak_method(f) if hasattr(f, '__self__') else weakref.ref(f)
|
||||
|
||||
|
||||
def resolve_ref(ref):
|
||||
"""Handles dereference of weakref."""
|
||||
if isinstance(ref, weakref.ref):
|
||||
ref = ref()
|
||||
return ref
|
||||
|
||||
|
||||
def bytes_to_bits(value):
|
||||
return value * 8
|
||||
|
||||
|
||||
Reference in New Issue
Block a user