can you open an issue/pull request on github?

Paolo

On Tuesday, May 12, 2015 at 7:06:47 PM UTC+2, Bernard Letourmy wrote:
>
> We  found a blocking issue in our app with some image download after 
> upgrading from 2.9.12 to 2.10.4
>
> It turned out to be a deadlock in CacheOnDisk class in case of exception 
> in our cache callback function, normally handled in our app
> without any issue until now.
>
> the new file_locks introduced in 2.10.1, (3e46e985bf15) acquired before 
> the cache app callback ( value = f() )
> with self.storage.acquire(CacheAbstract.cache_stats_name) 
> Is never released in case of exception in f()
> then next call to the CacheOnDisk during same request will block the 
> thread indefinitely.
>
> (CacheInRam should not have the same issue as self.locker.release() is 
> released before f())
>
> The following patch solves the issue for us.
> Hope it could help
>
> Bernard
>  
>
>> git diff -w  R-2.10.4 cache.py
>>
>> *diff --git a/gluon/cache.py b/gluon/cache.py*
>> *index f94937d..9729e6b 100644*
>> *--- a/gluon/cache.py*
>> *+++ b/gluon/cache.py*@@ -473,7 +473,12 @@ class 
>> CacheOnDisk(CacheAbstract):
>>          if item and ((dt is None) or (item[0] > now - dt)):
>>              value = item[1]
>>          else:
>> +            try:
>>                  value = f()
>> +            except:
>> +                self.storage.release(CacheAbstract.cache_stats_name)
>> +                self.storage.release(key)
>> +                raise
>>              self.storage[key] = (now, value)
>>              self.storage.safe_apply(CacheAbstract.cache_stats_name, 
>> inc_misses,
>>                                      default_value={'hit_total': 0, 
>> 'misses': 0})
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to