Fix circular import of scapy in dhcp (#56040)
* Fix circular import of scapy in dhcp * Tweak import, add comment * Tweak import, add comment * pylint
This commit is contained in:
parent
970a7f9662
commit
ff1b39cda6
1 changed files with 11 additions and 0 deletions
|
@ -279,6 +279,17 @@ class DHCPWatcher(WatcherBase):
|
|||
"""Start watching for dhcp packets."""
|
||||
# Local import because importing from scapy has side effects such as opening
|
||||
# sockets
|
||||
from scapy import ( # pylint: disable=import-outside-toplevel,unused-import # noqa: F401
|
||||
arch,
|
||||
)
|
||||
|
||||
#
|
||||
# Importing scapy.sendrecv will cause a scapy resync which will
|
||||
# import scapy.arch.read_routes which will import scapy.sendrecv
|
||||
#
|
||||
# We avoid this circular import by importing arch above to ensure
|
||||
# the module is loaded and avoid the problem
|
||||
#
|
||||
from scapy.sendrecv import ( # pylint: disable=import-outside-toplevel
|
||||
AsyncSniffer,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue