Skip to content

Commit

Permalink
Fix exception when running snmp subagent under python3.7 (sonic-net#130)
Browse files Browse the repository at this point in the history
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):sonic-net#12  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())sonic-net#12  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete#012    return future.result()sonic-net#12  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)sonic-net#12  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)sonic-net#12  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 <Task pending coro=<MIBUpdater.start() running at /usr/local/lib/python3.7/dist-packages/ax_interface/mib.py:34> 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.
  • Loading branch information
joyas-joseph authored May 6, 2020
1 parent 59aed32 commit c8e5757
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/ax_interface/mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c8e5757

Please sign in to comment.