mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2025-01-22 09:18:09 +00:00
Warn about working closing on drop
This commit is contained in:
parent
1266873f5d
commit
5cd6a1b102
1 changed files with 10 additions and 1 deletions
|
@ -42,6 +42,14 @@ impl Worker for LocalWorkerHandle {
|
|||
}
|
||||
}
|
||||
|
||||
struct WarnOnDrop(Uuid);
|
||||
|
||||
impl Drop for WarnOnDrop {
|
||||
fn drop(&mut self) {
|
||||
warn!("Worker {} closing", self.0);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn local_worker<State>(
|
||||
queue: String,
|
||||
processors: CachedProcessorMap<State>,
|
||||
|
@ -56,6 +64,7 @@ pub(crate) fn local_worker<State>(
|
|||
let handle = LocalWorkerHandle { tx, id, queue };
|
||||
|
||||
spawn(async move {
|
||||
let warn_on_drop = WarnOnDrop(id);
|
||||
debug!("Beginning worker loop for {}", id);
|
||||
if let Err(e) = server.request_job(Box::new(handle.clone())).await {
|
||||
error!("Couldn't request first job, bailing, {}", e);
|
||||
|
@ -72,6 +81,6 @@ pub(crate) fn local_worker<State>(
|
|||
break;
|
||||
}
|
||||
}
|
||||
warn!("Worker {} closing", id);
|
||||
drop(warn_on_drop);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue