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
Right now, if a user sends repeated KeyboardInterrupt signals it's possible for diskcache to get stuck in a locked state because the cleanup logic that's meant to unlock the cache never gets executed.
Use Case
In my case I'm writing software used by scientists who have a habit of holding down Ctrl+C or press it when they want their program to exit. Sometimes this causes diskcache to hang the next time they run their program since the cache is stuck in a locked state.
Workaround
My current workaround is to expire everything in the cache when the program starts:
ifmp.parent_process() isNone:
# Forcefully expire all cache entries to ensure we're starting fresh.# This only deletes 100 records at a time so we need to loop until the# deleted count returned by expire() is 0. This also will not evict# anything that does not have an expire time set.whileDISK_LRU_CACHE.expire(now=sys.float_info.max):
pass
This has several downsides though:
expire() is only available on Cache and not FanoutCache
This prevents values from being cached across runs of the program
If one instance of the program is currently running, kicking off another will expire values currently in use by the other.
Adds some (though minimal) overhead at the start of the program
Solutions
The only solution I can think of at the time of writing is to defer interrupt signals until after diskcache has relinquished control of any resources it acquired. This thread suggests a way to do this. Currently there's no way to do this myself without calling lower level diskcache APIs and giving up usage of the convenient diskcache.recipes.
The text was updated successfully, but these errors were encountered:
Summary
Right now, if a user sends repeated
KeyboardInterrupt
signals it's possible fordiskcache
to get stuck in a locked state because the cleanup logic that's meant to unlock the cache never gets executed.Use Case
In my case I'm writing software used by scientists who have a habit of holding down Ctrl+C or press it when they want their program to exit. Sometimes this causes
diskcache
to hang the next time they run their program since the cache is stuck in a locked state.Workaround
My current workaround is to expire everything in the cache when the program starts:
This has several downsides though:
expire()
is only available onCache
and notFanoutCache
Solutions
The only solution I can think of at the time of writing is to defer interrupt signals until after
diskcache
has relinquished control of any resources it acquired. This thread suggests a way to do this. Currently there's no way to do this myself without calling lower leveldiskcache
APIs and giving up usage of the convenientdiskcache.recipes
.The text was updated successfully, but these errors were encountered: