-
Notifications
You must be signed in to change notification settings - Fork 141
fix: race condition in image uploader #779
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Test that it works in multithreads environement with caches enabled - Test that it works in multithreads with cache disabled - when cache is enabled, test that cache hits for the second run - Do not use mock unless badly needed (See TestSingleImageUploader as exmple) - Do not import modules inside the test class (always add imports to the top of test file)
…threading_with_cache_enabled. No need to do that because `sequence_uploader.upload_images` is using inside multithreading. We can guranteee that sequence_uploader.upload_images won't be called in multithreads
…e. Try mock some internal implementation, e.g. if single_image_uploader.cache.get() is called and filehandle if filehandle is cached there
…. Let's make some changes in uploader.py 1. Make SingleImageUploader fully thread-safe, which means move _maybe_create_persistent_cache_instance to ImageSequenceUploader perhaps 2. Create the cache instance in ImageSequenceUploader and pass in the instance to SingleImageUploader to create the single image uploader instance 3. Use single image uploader instance for all uploads in ImageSequenceUploader Make change in implementation only for now (i.e. do not change tests).
…cache and SingleImageUploader.cache, which means you can update them after construction, and run assertions based on the cache instance
…_image_sequence_uploader_cache_hits_second_run Make sure test these scenario in that test: 1. make sure cache is enabled 2. for the first upload_images(a, b, c), make sure no caches are hit 3. fir the second upload_images(c, d, e), make sure c is using the cached value, d and e are not cached 4. eventually a, b, c, d, e are all cached
…uenceUploader has not errors
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
sequence_uploader.upload_imagesis using inside multithreading. We can guranteee that sequence_uploader.upload_images won't be called in multithreadssequence_uploader.upload_imagesin test_image_sequence_uploader_cache_hits_second_run