Skip to content

Commit

Permalink
Recreate a chunk in case of UnpicklingError (#7251)
Browse files Browse the repository at this point in the history
Resolved #7251
  • Loading branch information
azhavoro authored Dec 11, 2023
1 parent 72379e2 commit e472fad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Fixed

- Added workaround for corrupted cached chunks
(<https://github.com/opencv/cvat/pull/7243>)
(<https://github.com/opencv/cvat/pull/7243>, <https://github.com/opencv/cvat/pull/7251>)
8 changes: 7 additions & 1 deletion cvat/apps/engine/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import cv2
import PIL.Image
import pickle # nosec
from django.conf import settings
from django.core.cache import caches
from rest_framework.exceptions import NotFound, ValidationError
Expand Down Expand Up @@ -56,8 +57,13 @@ def create_item():
return item

slogger.glob.info(f'Starting to get chunk from cache: key {key}')
item = self._cache.get(key)
try:
item = self._cache.get(key)
except pickle.UnpicklingError:
slogger.glob.error(f'Unable to get item from cache: key {key}', exc_info=True)
item = None
slogger.glob.info(f'Ending to get chunk from cache: key {key}, is_cached {bool(item)}')

if not item:
item = create_item()
else:
Expand Down

0 comments on commit e472fad

Please sign in to comment.