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

Better tasking less locks #318

Conversation

joaoantoniocardoso
Copy link
Collaborator

@joaoantoniocardoso joaoantoniocardoso commented Nov 30, 2023

merge after #303

Comment on lines +69 to +84
// .service(
// web::scope("/thumbnail")
// // Add a rate limitter to prevent flood
// .wrap(
// RateLimiter::builder(
// InMemoryBackend::builder().build(),
// SimpleInputFunctionBuilder::new(std::time::Duration::from_secs(1), 4)
// .real_ip_key()
// .build(),
// )
// .add_headers()
// .build(),
// )
// .route("", web::get().to(pages::thumbnail)),
// )
Copy link
Collaborator Author

@joaoantoniocardoso joaoantoniocardoso Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be reworked with care to work with only one worker...

Comment on lines +385 to +466
// #[api_v2_operation]
// /// Provides a thumbnail file of the given source
// pub async fn thumbnail(thumbnail_file_request: web::Query<ThumbnailFileRequest>) -> HttpResponse {
// Ideally, we should be using `actix_web_validator::Query` instead of `web::Query`,
// but because paperclip (at least until 0.8) is using `actix-web-validator 3.x`,
// and `validator 0.14`, the newest api needed to use it along #[api_v2_operation]
// wasn't implemented yet, it doesn't compile.
// To workaround this, we are manually calling the validator here, using actix to
// automatically handle the validation error for us as it normally would.
// TODO: update this function to use `actix_web_validator::Query` directly and get
// rid of this workaround.
// if let Err(errors) = thumbnail_file_request.validate() {
// warn!("Failed validating ThumbnailFileRequest. Reason: {errors:?}");
// return actix_web::ResponseError::error_response(&actix_web_validator::Error::from(errors));
// }

// let source = thumbnail_file_request.source.clone();
// let quality = thumbnail_file_request.quality.unwrap_or(70u8);
// let target_height = thumbnail_file_request.target_height.map(|v| v as u32);

// match stream_manager::get_jpeg_thumbnail_from_source(source, quality, target_height).await {
// Some(Ok(image)) => HttpResponse::Ok().content_type("image/jpeg").body(image),
// None => HttpResponse::NotFound()
// .content_type("text/plain")
// .body(format!(
// "Thumbnail not found for source {:?}.",
// thumbnail_file_request.source
// )),
// Some(Err(error)) => HttpResponse::ServiceUnavailable()
// .reason("Thumbnail temporarily unavailable")
// .insert_header((header::RETRY_AFTER, 10))
// .content_type("text/plain")
// .body(format!(
// "Thumbnail for source {:?} is temporarily unavailable. Try again later. Details: {error:?}",
// thumbnail_file_request.source
// )),
// }
// }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be reworked with care to work with only one worker...

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The threads do not finish..

image

A shutdown mechanism like #314 is still necessary

@joaoantoniocardoso
Copy link
Collaborator Author

The threads do not finish..

image

A shutdown mechanism like #314 is still necessary

Even if you add the shutdown mechanism on top of this patch, your test will fail. If you have a while loop inside the drop, you need to allow more workers.

@patrickelectric
Copy link
Member

The threads do not finish..
image
A shutdown mechanism like #314 is still necessary

Even if you add the shutdown mechanism on top of this patch, your test will fail. If you have a while loop inside the drop, you need to allow more workers.

Indeed the method does not work with this approach, I'll check if there other ways for us to investigate this.

@joaoantoniocardoso joaoantoniocardoso force-pushed the better_tasking_less_locks branch from 5d3c4fd to 6e70998 Compare December 1, 2023 18:36
@joaoantoniocardoso
Copy link
Collaborator Author

Superposed by #377

@joaoantoniocardoso joaoantoniocardoso deleted the better_tasking_less_locks branch April 14, 2024 17:53
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

Successfully merging this pull request may close these issues.

2 participants