# Unregister Timers with parameters

I am trying to use a timer for a function, but I need to provide it a parameter so I'm using the example from https://docs.blender.org/api/blender2.8/bpy.app.timers.html:

import bpy
import functools

def print_message(message):
print("Message:", message)

bpy.app.timers.register(functools.partial(print_message, "Hello"), first_interval=2.0)


The problem is that I don't know how to unregister it. Trying with this:

if bpy.app.timers.is_registered(functools.partial(print_message, "World"):
bpy.app.timers.unregister(functools.partial(print_message, "World")


Or this:

if bpy.app.timers.is_registered(print_message):
bpy.app.timers.unregister(print_message)


Or even this:

   if bpy.app.timers.is_registered(functools):
bpy.app.timers.unregister(functools)


And a lot of other things, but that doesn't work. Any idea? Thanks!

• bpy.app.timers has not unregister function, but timer function can return False to stop execution, try look at this – RUben Jun 2 '19 at 14:26
• I have been able to unregister timers, it actually unregisters if I don't check if it's registered first (it does throw an error though, maybe it's trying to unregister itself twice). But the return None solution works great, so thanks for your help! – chafouin Jun 2 '19 at 14:34
• @RUben bpy.app.timers has an unregister function listed here – Ray Mairlot Jun 2 '19 at 15:11
• It's a bit weird that bpy.app.timers.is_registered doesn't work when using parameters. It must be expecting a specific argument that I don't know about. – chafouin Jun 3 '19 at 15:20