ipyaladin
ipyaladin copied to clipboard
Listeners functions do not catch their trigger if the widget is not fully loaded
What happens
Sometimes, the widget has not finished loading when the user attempts to call one of the listeners functions (add_table, target...) This can be trigered in two ways:
- users call the listeners in the same cells than the widget
- use of automatic executions of cells (like in testing or regeneration tools)
Possible ideas for fixes
- Implement an await on python side or async on javascript side?
- Rework the way we handle listenners
Refer to this doc for the choice of the solution : https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Low%20Level.html
Update: await on python side is a dead end.
Update2: doing the flag change in a thread as suggested here https://ipywidgets.readthedocs.io/en/7.6.5/examples/Widget%20Asynchronous.html did not work neither
import threading
thread = threading.Thread(target=exec, args=("self.update_wcs_flag = not self.update_wcs_flag", {'self': self}))
thread.daemon = True
thread.start()