You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromdogpile.cacheimportmake_regionTIMEOUT_SECONDS=10*60defmy_key_generator(namespace, fn):
fname=fn.__name__defgenerate_key(*arg):
# generate a key template:# "fname_%d_arg1_arg2_arg3..."# key_template = fname + "_" + "%d" + "_".join(str(s) for s in arg[1:])key_template=fname+"_"+"_".join(str(s) forsinarg)
returnkey_templatereturngenerate_keyregion=make_region(function_key_generator=my_key_generator).configure(
"dogpile.cache.redis",
expiration_time=TIMEOUT_SECONDS,
arguments={
"host": "localhost",
"port": 6379,
"db": 0,
"redis_expiration_time": TIMEOUT_SECONDS*2, # 2 hours"distributed_lock": True,
# thread_local_lock – bool, whether a thread-local Redis lock object should be used.# This is the default, but is not compatible with asynchronous runners, as they run in# a different thread than the one used to create the lock."thread_local_lock": False,
},
)
@region.cache_on_arguments()defload_user_info(user_id):
log.info(f"Called func {user_id}")
returnlambda: user_idprint(load_user_info(1))
This returns the pickle error, which is to be expected.
My question is is there a way when an exception happens on the dogpile side catch the exception, log the exception and return the actual value instead of totally failing the call?
The text was updated successfully, but these errors were encountered:
not yet. we have a PR for this on the deserialize side at #233. The contributor has not been around. Can you pick up this PR and we can add a similar handler for the serialize side?
This returns the pickle error, which is to be expected.
My question is is there a way when an exception happens on the dogpile side catch the exception, log the exception and return the actual value instead of totally failing the call?
The text was updated successfully, but these errors were encountered: