Commit 534ad49c authored by Javier Diaz's avatar Javier Diaz
Browse files

Code Cleanup

parent fe4af7af
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import grpc, asyncio, logging
import logging
from grpc.aio import ServicerContext
from typing import Optional
from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method_async
+4 −4
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
# limitations under the License.


import logging, signal, sys, threading, asyncio
import logging, signal, threading, asyncio
from prometheus_client import start_http_server
from common.Constants import ServiceNameEnum
from common.Settings import (
@@ -25,12 +25,12 @@ from .DltConnectorService import DltConnectorService
terminate = threading.Event()
LOGGER: logging.Logger = None

def signal_handler(signal, frame):
def signal_handler(signal, frame): # pylint: disable=redefined-outer-name
    LOGGER.warning('Terminate signal received')
    terminate.set()

async def main():
    global LOGGER
    global LOGGER # pylint: disable=global-statement

    log_level = get_log_level()
    logging.basicConfig(level=log_level, format="[%(asctime)s] %(levelname)s:%(name)s:%(message)s")
@@ -59,7 +59,7 @@ async def main():
    await grpc_service.start()

    # Wait for Ctrl+C or termination signal
    while not terminate.wait(timeout=1.0):
    while not terminate.is_set():
        await asyncio.sleep(1.0)

    LOGGER.info('Terminating...')
+1 −1
Original line number Diff line number Diff line
@@ -20,5 +20,5 @@ def record_exists(record : DltRecord) -> bool:
    exists = exists and (record.record_id.type != DLTRECORDTYPE_UNDEFINED)
    exists = exists and (len(record.record_id.record_uuid.uuid) > 0)
    #exists = exists and (record.operation != DLTRECORDOPERATION_UNDEFINED)
    #exists = exists and (len(record.data_json) > 0)
    #exists = exists and (len(record.data_json) > 0) #It conflicts as sometimes records do not have a data_json.
    return exists
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ def main():
    signal.signal(signal.SIGINT,  signal_handler)
    signal.signal(signal.SIGTERM, signal_handler)

    LOGGER.info('Starting Interdomain Service...')
    LOGGER.info('Starting...')

    # Start metrics server
    metrics_port = get_metrics_port()
@@ -71,7 +71,7 @@ def main():
    #     topology_abstractor.start()

        # Subscribe to Context Events
    #dlt_enabled = is_dlt_enabled()
    #dlt_enabled = is_dlt_enabled() #How to change the config?
    dlt_enabled = True
    if dlt_enabled:
        LOGGER.info('Starting DLT functionality...')
+1 −2
Original line number Diff line number Diff line
@@ -16,10 +16,9 @@ import logging
import asyncio


from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Tuple
from common.proto.context_pb2 import Device, Link, Service, Slice, TopologyId
from common.proto.dlt_connector_pb2 import DltDeviceId, DltLinkId, DltServiceId, DltSliceId
from common.tools.grpc.Tools import grpc_message_to_json_string
from context.client.ContextClient import ContextClient
from dlt.connector.client.DltConnectorClientAsync import DltConnectorClientAsync

Loading