Skip to content

Commit a956817

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Use oslo_service's SignalHandler for signals" into stable/2023.1
2 parents 5f42221 + b4189db commit a956817

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import functools
2020
import multiprocessing
2121
import operator
22-
import signal
2322
import threading
2423
import types
2524
import uuid
@@ -43,6 +42,7 @@
4342
from oslo_config import cfg
4443
from oslo_db import exception as os_db_exc
4544
from oslo_log import log
45+
from oslo_service import service as oslo_service
4646
from oslo_utils import timeutils
4747
from ovsdbapp.backend.ovs_idl import idlutils
4848

@@ -312,8 +312,9 @@ def _setup_hash_ring(self):
312312
themselves to the hash ring.
313313
"""
314314
# Attempt to remove the node from the ring when the worker stops
315+
sh = oslo_service.SignalHandler()
315316
atexit.register(self._remove_node_from_hash_ring)
316-
signal.signal(signal.SIGTERM, self._remove_node_from_hash_ring)
317+
sh.add_handler("SIGTERM", self._remove_node_from_hash_ring)
317318

318319
admin_context = n_context.get_admin_context()
319320
if not self._hash_ring_probe_event.is_set():

neutron/plugins/ml2/ovo_rpc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
import atexit
1515
import queue
16-
import signal
1716
import threading
1817
import traceback
1918
import weakref
@@ -24,6 +23,7 @@
2423
from neutron_lib import context as n_ctx
2524
from neutron_lib.db import api as db_api
2625
from oslo_log import log as logging
26+
from oslo_service import service
2727

2828
from neutron.api.rpc.callbacks import events as rpc_events
2929
from neutron.api.rpc.handlers import resources_rpc
@@ -38,8 +38,9 @@
3838

3939
def _setup_change_handlers_cleanup():
4040
atexit.register(_ObjectChangeHandler.clean_up)
41-
signal.signal(signal.SIGINT, _ObjectChangeHandler.clean_up)
42-
signal.signal(signal.SIGTERM, _ObjectChangeHandler.clean_up)
41+
sh = service.SignalHandler()
42+
sh.add_handler("SIGINT", _ObjectChangeHandler.clean_up)
43+
sh.add_handler("SIGTERM", _ObjectChangeHandler.clean_up)
4344

4445

4546
class _ObjectChangeHandler(object):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ oslo.privsep>=2.3.0 # Apache-2.0
4242
oslo.reports>=1.18.0 # Apache-2.0
4343
oslo.rootwrap>=5.15.0 # Apache-2.0
4444
oslo.serialization>=2.25.0 # Apache-2.0
45-
oslo.service>=2.8.0 # Apache-2.0
45+
oslo.service>=3.1.2 # Apache-2.0
4646
oslo.upgradecheck>=1.3.0 # Apache-2.0
4747
oslo.utils>=4.8.0 # Apache-2.0
4848
oslo.versionedobjects>=1.35.1 # Apache-2.0

0 commit comments

Comments
 (0)