Let's say I have a function that updates some internal states of the application:
def on_change(*args, **kwargs):
pass # some compute intensive state change
This function can run up to hundred times a second (due to many mousewheel events triggering the update) - I would only like to execute the above function once and only the last call should be executed.
What is the best design pattern for managing such a situation? The only way I can think of is spawning a separate thread for each on_change call and share a variable between them, but this sounds overly messy...
Thanks!
class threading.Timerandcancel()