I see `task_input_hash` uses `fn.__<http://code__....
# ask-community
m
I see
task_input_hash
uses
fn.__<http://code__.co|code__.co>_code.hex()
but this value seems to remain the same if I update constants inside the function, e.g.
return 1+2
and
return 1+3
both return the same hex value, so changing constants in a function doesn't appear to bust the cache like it should. is this the expected behaviour?
c
great catch - it looks like
co_code
doesn't contain byte information about constants (ref: https://stackoverflow.com/questions/64534943/determine-if-a-python-function-has-changed). This seems easy enough to fix although it will have unexpected cache-busting behavior across an upgrade; as a workaround you can use your own cache key function that includes constants like so:
Copy code
def my_cache_fn(context, arguments):
       return hash_objects(
        context.task.task_key,              context.task.fn.__code__.co_code.hex(),
context.task.fn.__code__.co_consts.hex(),
        arguments,
    )
d
@Chris White Will this bug be fixed anytime soon?