Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django storage class instantiated every time #508

Closed
cristianocca opened this issue Jul 28, 2017 · 3 comments
Closed

Django storage class instantiated every time #508

cristianocca opened this issue Jul 28, 2017 · 3 comments

Comments

@cristianocca
Copy link

https://github.com/jazzband/sorl-thumbnail/blob/master/sorl/thumbnail/default.py#L24

Is it needed that the storage class is created every time it's needed? What happens if the storage class has a slow constructor? This happens with a custom AWS S3 storage class, that will check for the bucket on class construction only.

@cristianocca
Copy link
Author

Sorry, it seems the culprit is here, when rendering images:

https://github.com/jazzband/sorl-thumbnail/blob/master/sorl/thumbnail/images.py#L40

@WhyNotHugo WhyNotHugo changed the title Django strage class instantiated every time Django storage class instantiated every time Sep 22, 2017
@bartels
Copy link

bartels commented Jan 21, 2019

This appears to be the same bug as #301

It's particularly bad with the latest boto3 storage from django-storages, as it adds a large delay for each thumbnail generated.

It looks to be due to the behavior of instantiating a new storage instance for each thumbnail when deserializing from the cache. What would fix it is having some module level variable to cache the storage instances. That way only a single storage instance would be initialized for each storage type.

@claudep
Copy link
Contributor

claudep commented Aug 15, 2023

Duplicate of #301

@claudep claudep marked this as a duplicate of #301 Aug 15, 2023
@claudep claudep closed this as completed Aug 15, 2023
claudep pushed a commit that referenced this issue Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants