From 4514dacd26f8f9b7bbd69547bab027a9c2037303 Mon Sep 17 00:00:00 2001 From: Aliaksandr Nikitsin Date: Thu, 26 Sep 2024 17:23:14 +0200 Subject: [PATCH] fix device disconnected whilst monitoring --- framework/python/src/net_orc/network_orchestrator.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/framework/python/src/net_orc/network_orchestrator.py b/framework/python/src/net_orc/network_orchestrator.py index 4b3a032f7..63ba80d7d 100644 --- a/framework/python/src/net_orc/network_orchestrator.py +++ b/framework/python/src/net_orc/network_orchestrator.py @@ -17,6 +17,7 @@ import json import os from scapy.all import sniff, wrpcap, BOOTP, AsyncSniffer +from scapy.error import Scapy_Exception import shutil import subprocess import sys @@ -306,9 +307,13 @@ def _start_device_monitor(self, device): if not self._ip_ctrl.check_interface_status( self._session.get_device_interface()): - sniffer.stop() - self._session.set_status(TestrunStatus.CANCELLED) - LOGGER.error('Device interface disconnected, cancelling Testrun') + try: + sniffer.stop() + except Scapy_Exception: + LOGGER.error('Device adapter disconnected whilst monitoring.') + finally: + self._session.set_status(TestrunStatus.CANCELLED) + LOGGER.error('Device interface disconnected, cancelling Testrun') LOGGER.debug('Writing packets to monitor.pcap') wrpcap(os.path.join(device_runtime_dir, 'monitor.pcap'),