From 7460f66e237910be408c6210f110eaed7945fb4d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 14 Oct 2026 09:04:43 -0400 Subject: [PATCH] Workaround some bad pysnmp assumptions about importing importlib --- confluent_server/confluent/snmputil.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/confluent_server/confluent/snmputil.py b/confluent_server/confluent/snmputil.py index d47ceed1..986c5d20 100644 --- a/confluent_server/confluent/snmputil.py +++ b/confluent_server/confluent/snmputil.py @@ -25,6 +25,13 @@ import asyncio import confluent.exceptions as exc import inspect import socket +try: + # Some pysnmp installs expect util to be an attribute of importlib, but that doesn't naturally happen reliably + # So we prime the pump by importing it the proper way, then pysnmp can succesfully do it the wrong way + import importlib.util # noqa: F401 +except ImportError: + importlib = None + import pysnmp.hlapi.asyncio as snmp async def _get_transport(name):