tick_delays changes
Posted: Sat Jan 02, 2016 3:29 pm
We have updated our delaying mechanism to implement the changes proposed in issue #95. There were also a few issues e.g. with cancelling a delay (reported in the issue) and delays continued running after unloading the plugin which created the delay. These issues are now fixed!
Old example:
New example:
Old example:
Syntax: Select all
from listeners.tick import tick_delays
def delayed_callback(x, y):
print('Delayed callback', x, y)
delay = tick_delays.delay(3, delayed_callback, 'test', 123)
# Cancel the delay
delay.cancel()
New example:
Syntax: Select all
from listeners.tick import Delay
def delayed_callback(x, y):
print('Delayed callback', x, y)
delay = Delay(3, delayed_callback, 'test', 123)
# Prints True
print(delay.running)
# Cancel the delay
delay.cancel()
# Prints False, because it has been cancelled and isn't running anymore
print(delay.running)
# Sometimes you might also want to cancel the delay and call the callback immediately.
# This can be done by simply calling the Delay object
delay()