mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Do all of dhcp scapy startup in the executor (#57392)
This commit is contained in:
parent
49d97e13de
commit
be8724a6f8
@ -276,6 +276,10 @@ class DHCPWatcher(WatcherBase):
|
|||||||
self._sniffer.stop()
|
self._sniffer.stop()
|
||||||
|
|
||||||
async def async_start(self):
|
async def async_start(self):
|
||||||
|
"""Start watching for dhcp packets."""
|
||||||
|
await self.hass.async_add_executor_job(self._start)
|
||||||
|
|
||||||
|
def _start(self):
|
||||||
"""Start watching for dhcp packets."""
|
"""Start watching for dhcp packets."""
|
||||||
# Local import because importing from scapy has side effects such as opening
|
# Local import because importing from scapy has side effects such as opening
|
||||||
# sockets
|
# sockets
|
||||||
@ -319,7 +323,7 @@ class DHCPWatcher(WatcherBase):
|
|||||||
conf.sniff_promisc = 0
|
conf.sniff_promisc = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(_verify_l2socket_setup, FILTER)
|
_verify_l2socket_setup(FILTER)
|
||||||
except (Scapy_Exception, OSError) as ex:
|
except (Scapy_Exception, OSError) as ex:
|
||||||
if os.geteuid() == 0:
|
if os.geteuid() == 0:
|
||||||
_LOGGER.error("Cannot watch for dhcp packets: %s", ex)
|
_LOGGER.error("Cannot watch for dhcp packets: %s", ex)
|
||||||
@ -330,7 +334,7 @@ class DHCPWatcher(WatcherBase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(_verify_working_pcap, FILTER)
|
_verify_working_pcap(FILTER)
|
||||||
except (Scapy_Exception, ImportError) as ex:
|
except (Scapy_Exception, ImportError) as ex:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Cannot watch for dhcp packets without a functional packet filter: %s",
|
"Cannot watch for dhcp packets without a functional packet filter: %s",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user