-
Notifications
You must be signed in to change notification settings - Fork 34
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
Meet a issue when I add the notification handler to Job #32
Comments
I found the code in NotificationCreator::add,
Should the two tokio::spawn calling be using .await? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I create a new Job for shared Scheduler, the job could not add notication handler.
let mut jobsch = get_scheduler().clone();
jobsch.shutdown().await?;
let job = Job::new_repeated_async(Duration::from_millis(100u64), run)?;
// job.on_done_notification_add(&jobsch, async move |_, _, |{});
log::info!("Do add a job notification {}", jobsch.inited.read().await);
// below code will locked this thread
match job.on_notifications_add(&jobsch, Box::new(|job_id, notification_id, type_of_notification| {
Box::pin(async move {
println!("Job {:?} was completed, notification {:?} ran ({:?})", job_id, notification_id, type_of_notification);
})
}), vec![tokio_cron_scheduler::JobNotification::Done]).await {
Ok() => {},
Err(err) => {
log::info!("add notic failed {}", err);
},
}
log::info!("Do add a job into scheduler"); // this code will not be reached.
get_scheduler().add(job).await
The text was updated successfully, but these errors were encountered: