From a91736d3698f640c6c3cf67001b32f32fb8813f0 Mon Sep 17 00:00:00 2001 From: Kyrylo Yatsenko Date: Wed, 28 Oct 2026 17:31:52 +0200 Subject: [PATCH] Add ScapyNotRunningException Currently when stopping AsyncSniffer there is no easy way to tell whether the sniffer just was already stopped or some other error occured. Add separate ScapyNotRunningException for that. AI-Assisted: no --- scapy/error.py | 4 ++++ scapy/sendrecv.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scapy/error.py b/scapy/error.py index ff3fdc13eb4..63e50b7141b 100644 --- a/scapy/error.py +++ b/scapy/error.py @@ -39,6 +39,10 @@ class ScapyNoDstMacException(Scapy_Exception): pass +class ScapyNotRunningException(Scapy_Exception): + pass + + class ScapyFreqFilter(logging.Filter): def __init__(self): # type: () -> None diff --git a/scapy/sendrecv.py b/scapy/sendrecv.py index 4919c1b8846..5ac26051e5c 100644 --- a/scapy/sendrecv.py +++ b/scapy/sendrecv.py @@ -33,7 +33,8 @@ QueryAnswer, SndRcvList, ) -from scapy.error import log_runtime, log_interactive, Scapy_Exception +from scapy.error import log_runtime, log_interactive, \ + Scapy_Exception, ScapyNotRunningException from scapy.base_classes import Gen, SetGen, ScopedIP from scapy.sessions import DefaultSession from scapy.supersocket import SuperSocket, IterSocket @@ -1399,7 +1400,7 @@ def stop(self, join=True): return self.results return None else: - raise Scapy_Exception("Not running ! (check .running attr)") + raise ScapyNotRunningException("Not running ! (check .running attr)") def join(self, *args, **kwargs): # type: (*Any, **Any) -> None