From c8e5757b7f5495607bbf13d936f106991c13ddf5 Mon Sep 17 00:00:00 2001 From: joyas-joseph <51463120+joyas-joseph@users.noreply.github.com> Date: Wed, 6 May 2020 15:34:27 -0700 Subject: [PATCH] Fix exception when running snmp subagent under python3.7 (#130) May 5 21:35:16.852142 sonic ERR snmp#snmp-subagent [sonic_ax_impl] ERROR: Uncaught exception in sonic_ax_impl.main#012Traceback (most recent call last):#012 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/main.py", line 70, in main#012 event_loop.run_until_complete(agent.run_in_event_loop())#012 File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete#012 return future.result()#012 File "/usr/local/lib/python3.7/dist-packages/ax_interface/agent.py", line 37, in run_in_event_loop#012 background_task = self.mib_table.start_background_tasks(self.oid_updaters_enabled)#012 File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 276, in start_background_tasks#012 task = event._loop.create_task(fut)#012 File "/usr/lib/python3.7/asyncio/base_events.py", line 405, in create_task#012 task = tasks.Task(coro, loop=self)#012TypeError: a coroutine was expected, got cb=[MIBTable._done_background_task_callback() at /usr/local/lib/python3.7/dist-packages/ax_interface/mib.py:263]> We really do not need to wrap the future within a task. This also addresses the issue where the subagent would not exit on SIGTERM. --- src/ax_interface/mib.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ax_interface/mib.py b/src/ax_interface/mib.py index 1921555997c0..792de1e114e0 100644 --- a/src/ax_interface/mib.py +++ b/src/ax_interface/mib.py @@ -281,8 +281,7 @@ def start_background_tasks(self, event): updater.run_event = event fut = asyncio.ensure_future(updater.start()) fut.add_done_callback(MIBTable._done_background_task_callback) - task = event._loop.create_task(fut) - tasks.append(task) + tasks.append(fut) return asyncio.gather(*tasks, loop=event._loop) def _find_parent_prefix(self, item):