Skip to content

Commit

Permalink
Set threaded to False by default in sr1. (#4641)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
polybassa authored Feb 3, 2025
1 parent 0f2b394 commit 8eec6e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scapy/supersocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8eec6e8

Please sign in to comment.