mvniekerk / tokio-cron-scheduler

Schedule tasks on Tokio using cron-like annotation
Apache License 2.0
529 stars 59 forks source link

Can't add job from within another job #34

Closed ghost closed 1 year ago

ghost commented 2 years ago

Hi, I would like, under some circumstances, add an one-shoot job Job::new_one_shot_async from within Job::new_async, but job_sched.add(job).await never returns, and on terminate I receive errors like "tokio_cron_scheduler::job::creator] Could not receive done from add RecvError".

I don't know if this is impossible by design, or I am doing something wrong. Stopping, adding, and starting the scheduler again doesn't help. Sadly, tracking async program flow, to find the reason, is quite difficult.

mvniekerk commented 2 years ago

Hi @marmidrcl , thanks for the report. If you don't mind creating an example repository?

So what I'm thinking what's happening here is that there's a write lock on the scheduler and what you've got here is in essence a lock contention issue.

mvniekerk commented 1 year ago

Hi @marmidrcl Any update on this? I'd like to close up the issue.

ghost commented 1 year ago

Hi, It's ben a long time I attempted to use it and the solution was redesigned entirely, so I'm no longer able to reproduce the issue. I suspect that I over-engineered something back then.