From 417a15589f7e2cfc3f752cf5e6c403bddebe46b0 Mon Sep 17 00:00:00 2001 From: clavay Date: Tue, 6 Feb 2024 16:39:24 +0100 Subject: [PATCH] fix BP not exist while deleting a device --- pyscada/signals.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pyscada/signals.py b/pyscada/signals.py index 1092bd85..518e4473 100755 --- a/pyscada/signals.py +++ b/pyscada/signals.py @@ -133,12 +133,16 @@ def _del_daq_daemons(sender, instance, **kwargs): label=f"pyscada.{instance.protocol.protocol}-{instance.id}", ) except BackgroundProcess.DoesNotExist: - # for modbus protocol - bp = BackgroundProcess.objects.get( - done=False, - failed=False, - label__startswith=f"pyscada.{instance.protocol.protocol}-{instance.id}", - ) + try: + # for modbus protocol + bp = BackgroundProcess.objects.get( + done=False, + failed=False, + label__startswith=f"pyscada.{instance.protocol.protocol}-{instance.id}", + ) + except BackgroundProcess.DoesNotExist: + # BP not created, cannot stop + return False except Exception as e: logger.debug(e) return False