Code Duplication    Length = 13-13 lines in 2 locations

kytos/core/helpers.py 2 locations

@@ 227-239 (lines=13) @@
224
            and also decorated as an asyncio task.
225
        """
226
        # pylint: disable=unused-argument,broad-except
227
        async def handler_context(*args, **kwargs):
228
            """Async handler's execution context."""
229
            cls, kytos_event = args[0], args[1]
230
            try:
231
                result = await handler(*args)
232
            except Exception:
233
                result = None
234
                traceback_str = traceback.format_exc()
235
                LOG.error(f"alisten_to handler: {handler}, "
236
                          f"args: {args} traceback: {traceback_str}")
237
                if hasattr(cls, "controller"):
238
                    cls.controller.dead_letter.add_event(kytos_event)
239
            return result
240
241
        async def handler_context_apm(*args, apm_client=None):
242
            """Async handler's execution context with APM instrumentation."""
@@ 137-149 (lines=13) @@
134
                return
135
136
        # pylint: disable=unused-argument
137
        def handler_context(*args, **kwargs):
138
            """Handler's context for ThreadPool."""
139
            cls, kytos_event = args[0], args[1]
140
            try:
141
                result = handler(*args)
142
            except Exception:
143
                result = None
144
                traceback_str = traceback.format_exc()
145
                LOG.error(f"listen_to handler: {handler}, "
146
                          f"args: {args} traceback: {traceback_str}")
147
                if hasattr(cls, "controller"):
148
                    cls.controller.dead_letter.add_event(kytos_event)
149
            return result
150
151
        def handler_context_apm(*args, apm_client=None):
152
            """Handler's context for ThreadPool APM instrumentation."""