From 8eec6e8f40291dd4372f556e0be33565c12e2dc4 Mon Sep 17 00:00:00 2001 From: Nils Weiss Date: Mon, 3 Feb 2025 01:46:02 +0100 Subject: [PATCH] Set threaded to False by default in sr1. (#4641) * Proposal: Set threaded to False in sr1. If the user doesn't specifiy threaded, we should set it to False in sr1 to eliminate the overhead of a thread creation * Apply feedback --- scapy/supersocket.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scapy/supersocket.py b/scapy/supersocket.py index 592c581d41f..9744fd841bf 100644 --- a/scapy/supersocket.py +++ b/scapy/supersocket.py @@ -250,6 +250,10 @@ def sr1(self, *args, **kargs): """Send one packet and receive one answer """ from scapy import sendrecv + # if not explicitly specified by the user, + # set threaded to False in sr1 to remove the overhead + # for a Thread creation + kargs.setdefault("threaded", False) ans = sendrecv.sndrcv(self, *args, **kargs)[0] # type: SndRcvList if len(ans) > 0: pkt = ans[0][1] # type: Packet