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
The @cached_stampede decorator throws UnboundLocalError when a decorated function is called multiple times when cache is empty.
Error:
Error handling request
Traceback (most recent call last):
File "C:\Git\test_project\.venv\Lib\site-packages\aiohttp\web_protocol.py", line 410, in start
resp = yield from self._request_handler(request)
File "C:\Git\test_project\.venv\Lib\site-packages\aiohttp\web.py", line 325, in _handle
resp = yield from handler(request)
File "C:\Git\test_project\.venv\Lib\site-packages\aiohttp\web_middlewares.py", line 93, in impl
return (yield from handler(request))
File "<ipython-input-1-bfa0dca86818>", line 15, in test
await test_func(val)
File "C:\Git\test_project\.venv\Lib\site-packages\aiocache\decorators.py", line 69, in wrapper
return await self.decorator(f, *args, **kwargs)
File "C:\Git\test_project\.venv\Lib\site-packages\aiocache\decorators.py", line 170, in decorator
return result
UnboundLocalError: local variable 'result' referenced before assignment
Hey @borisnaydis Ive (well @pfreixes) found the cause. Basically this is happening because when hitting F5 in the same browser tab, previous request is cancelled and leads to an unexpected path which raises this unbound result exception. I take two actions from here:
I will make this path play nicer, will raise the Cancelled Error in case this happens so instead an unbound error, we will se a cancelled error (which is expected)
__aexit__ was returning whether asyncio Event was removed or not. In some cases this was avoiding the context manager to propagate exceptions happening inside. Now its not returning anything and will raise always any exception raised from inside
The
@cached_stampede
decorator throwsUnboundLocalError
when a decorated function is called multiple times when cache is empty.Error:
Steps to reproduce:
Go to http://localhost:8080/anything_you_like
Hit the F5 key fast several times.
The text was updated successfully, but these errors were encountered: