File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -247,14 +247,17 @@ def _wrapped(*args, **kwds):
247
247
# try to get result from cache
248
248
try :
249
249
result = cache [key ]
250
+ except KeyError :
251
+ pass
252
+ else :
253
+ # A NOTE FOR ME: we don't want to catch KeyError exceptions from `callback`
254
+ # so don't wrap it with try except
250
255
hits += 1
251
256
252
257
if callback is not None :
253
258
callback (EVENT_HIT , key , result )
254
259
255
260
return _copy_if_need (result , level = copy_level )
256
- except KeyError :
257
- pass
258
261
259
262
with locks [key ]:
260
263
if exceptions .get (key , None ) is not None :
@@ -327,6 +330,11 @@ async def _wrapped(*args, **kwds):
327
330
# try to get result from cache
328
331
try :
329
332
result = cache [key ]
333
+ except KeyError :
334
+ pass
335
+ else :
336
+ # A NOTE FOR ME: we don't want to catch KeyError exceptions from `callback`
337
+ # so don't wrap it with try except
330
338
hits += 1
331
339
332
340
if callback is not None :
@@ -335,8 +343,6 @@ async def _wrapped(*args, **kwds):
335
343
await awaitable
336
344
337
345
return _copy_if_need (result , level = copy_level )
338
- except KeyError :
339
- pass
340
346
341
347
async with locks [key ]:
342
348
if exceptions .get (key , None ) is not None :
You can’t perform that action at this time.
0 commit comments