kytos-ng / kytos

Kytos SDN Platform. Kytos is designed to be easy to install, use, develop and share Network Apps (NApps).
https://kytos-ng.github.io/
MIT License
2 stars 7 forks source link

feat: queue `asyncio.Task`(s) consumers supervision or handle broad except #476

Open viniarck opened 1 month ago

viniarck commented 1 month ago

Related to issue #475:

kytos $> controller._tasks
Out[163]:
[<Task pending name='Task-3' coro=<Controller.start_controller.<locals>._run_api_server_thread() running at /usr/local/lib/python3.9/dist-packages/kytos/core/controller.py:346> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7faf03e4cd90>()]> cb=[Controller.start_controller.<locals>._stop_loop() at /usr/local/lib/python3.9/dist-packages/kytos/core/controller.py:329]>,
 <Task finished name='Task-4' coro=<Controller.event_handler() done, defined at /usr/local/lib/python3.9/dist-packages/kytos/core/controller.py:583> exception=AttributeError("'tuple' object has no attribute 'close'")>,
 <Task pending name='Task-5' coro=<Controller.event_handler() running at /usr/local/lib/python3.9/dist-packages/kytos/core/controller.py:588> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fb03c079a30>()]>>,
 <Task pending name='Task-6' coro=<Controller.event_handler() running at /usr/local/lib/python3.9/dist-packages/kytos/core/controller.py:588> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7faf1e7534f0>()]>>,
 <Task finished name='Task-7' coro=<Controller.msg_out_event_handler() done, defined at /usr/local/lib/python3.9/dist-packages/kytos/core/controller.py:607> exception=DeprecationWarning("Using sendall() method on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.")>,
 <Task pending name='Task-8' coro=<Controller.event_handler() running at /usr/local/lib/python3.9/dist-packages/kytos/core/controller.py:588> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7faedb48e1c0>()]>>]

These tasks are critical for core functionality so, they shouldn't crash and gets finished. Ideally, there should be a handle broad exc support here while logging the traceback and/or supervision of the task (trying to be as reliable with what's possible in Python land)