Shut down faster (don't wait for crawl delays)
This commit is contained in:
parent
a60ace0482
commit
806192fab5
|
@ -78,7 +78,7 @@ pub struct TaskContext {
|
|||
impl TaskContext {
|
||||
pub async fn run(mut self) -> anyhow::Result<()> {
|
||||
// Get a domain to process
|
||||
while !self.graceful_stop.load(Ordering::Relaxed) {
|
||||
while !self.graceful_stop.load(Ordering::SeqCst) {
|
||||
let domain = {
|
||||
let txn = self.store.ro_txn()?;
|
||||
txn.acquire_random_active_domain(self.busy_domains.clone())?
|
||||
|
@ -196,7 +196,17 @@ impl TaskContext {
|
|||
|
||||
if let Some(wait_until) = wait_until.take() {
|
||||
// Sleep to respect a crawl-delay
|
||||
tokio::time::sleep_until(wait_until).await;
|
||||
tokio::select! {
|
||||
_ = tokio::time::sleep_until(wait_until) => {
|
||||
|
||||
}
|
||||
_ = self.notify.notified() => {
|
||||
if self.graceful_stop.load(Ordering::SeqCst) {
|
||||
// It's time to shut down
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let delay = if let Some(robot_rules) = current_robot_rules.as_ref() {
|
||||
|
|
Loading…
Reference in New Issue