Change default timeout for operations in SNMP component (#68230)

This commit is contained in:
wchan-ranelagh 2022-03-17 02:10:46 -07:00 committed by GitHub
parent aabfa08834
commit fc693001a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -16,6 +16,7 @@ DEFAULT_HOST = "localhost"
DEFAULT_NAME = "SNMP"
DEFAULT_PORT = "161"
DEFAULT_PRIV_PROTOCOL = "none"
DEFAULT_TIMEOUT = 8
DEFAULT_VERSION = "1"
DEFAULT_VARTYPE = "none"

View file

@ -48,6 +48,7 @@ from .const import (
DEFAULT_NAME,
DEFAULT_PORT,
DEFAULT_PRIV_PROTOCOL,
DEFAULT_TIMEOUT,
DEFAULT_VERSION,
MAP_AUTH_PROTOCOLS,
MAP_PRIV_PROTOCOLS,
@ -125,14 +126,14 @@ async def async_setup_platform(
authProtocol=getattr(hlapi, MAP_AUTH_PROTOCOLS[authproto]),
privProtocol=getattr(hlapi, MAP_PRIV_PROTOCOLS[privproto]),
),
UdpTransportTarget((host, port)),
UdpTransportTarget((host, port), timeout=DEFAULT_TIMEOUT),
ContextData(),
]
else:
request_args = [
SnmpEngine(),
CommunityData(community, mpModel=SNMP_VERSIONS[version]),
UdpTransportTarget((host, port)),
UdpTransportTarget((host, port), timeout=DEFAULT_TIMEOUT),
ContextData(),
]