wip
This commit is contained in:
@@ -41,7 +41,7 @@ pub struct ChromiumCoordinator {
|
||||
|
||||
impl ChromiumCoordinator {
|
||||
const NUMBER_OF_INSTANCES: usize = 1; // TODO: make this configurable
|
||||
|
||||
|
||||
pub async fn new() -> Self {
|
||||
let instances: Arc<Mutex<Vec<BrowserHolder>>> = Arc::new(Mutex::new(Vec::with_capacity(Self::NUMBER_OF_INSTANCES)));
|
||||
trace!("creating {} Chromium instances", Self::NUMBER_OF_INSTANCES);
|
||||
@@ -63,7 +63,7 @@ impl ChromiumCoordinator {
|
||||
}
|
||||
|
||||
fn spawn_browser(&self) {
|
||||
let instances = self.instances.clone();
|
||||
let instances = self.instances.clone();
|
||||
tokio::spawn(async move {
|
||||
debug!("spawn new instance of browser");
|
||||
// Create new instance
|
||||
@@ -133,7 +133,7 @@ impl<'r> FromRequest<'r> for BrowserHolder {
|
||||
let coordinator = request.rocket().state::<ChromiumCoordinator>().unwrap();
|
||||
let get_instance = coordinator.get_browser();
|
||||
pin_mut!(get_instance); // TODO: wth?
|
||||
let result = match tokio::time::timeout(std::time::Duration::from_secs(10), &mut get_instance).await {
|
||||
match tokio::time::timeout(std::time::Duration::from_secs(10), &mut get_instance).await {
|
||||
Ok(maybebrowser) => match maybebrowser {
|
||||
Ok(browser) => Outcome::<BrowserHolder, ()>::Success(browser),
|
||||
Err(_) => {
|
||||
@@ -145,9 +145,6 @@ impl<'r> FromRequest<'r> for BrowserHolder {
|
||||
error!("Can't create new instance of browser (timeout)");
|
||||
Outcome::<BrowserHolder, ()>::Error((Status::InternalServerError, ()))
|
||||
}
|
||||
};
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user