You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The synchronous API (pysnmp.hlapi.getCmd and friends) should function when run in a thread or other contexts which may not have a running event loop.
Actual behavior
When running e.g. getCmd in a thread, I see the following error:
Exception in thread Thread-1 (get):
Traceback (most recent call last):
File ".../python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File ".../python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File ".../repro.py", line 10, in get
pysnmp.hlapi.getCmd(
File ".../python3.12/site-packages/pysnmp/hlapi/asyncio/sync/cmdgen.py", line 97, in getCmd
loop = asyncio.get_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^
File ".../python3.12/asyncio/events.py", line 702, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-1 (get)'.
The primary goal to introduce those sync methods was to enable quick migration to 6.x releases, but we don't feel the current PySNMP code base was well designed with all asyncio best practices.
The current plan to retire the sync version of those methods in a future release, so people are suggested to fully migrate to the async version.
Expected behavior
The synchronous API (
pysnmp.hlapi.getCmd
and friends) should function when run in a thread or other contexts which may not have a running event loop.Actual behavior
When running e.g.
getCmd
in a thread, I see the following error:Detailed steps
Here's a simple reproducing script:
I'm working around this right now by just using the async API via
Python package information
6.1.2
Operating system information
Debian 13, Windows 10
Python information
Python 3.8.12, 3.9.13, 3.12.4
(Optional) Contents of your test script
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: