Skip to content
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

Spawn async jobs in ntex #119

Open
photino opened this issue Jul 15, 2024 · 0 comments
Open

Spawn async jobs in ntex #119

photino opened this issue Jul 15, 2024 · 0 comments
Labels
bonus We can offer a bonus for someone who fix this issue. enhancement New feature or request

Comments

@photino
Copy link
Collaborator

photino commented Jul 15, 2024

How can we run async jobs in the background? I have tried

System::new("scheduler")
    .system()
    .arbiter()
    .spawn(Box::pin(async move {
        loop {
            scheduler.tick().await;

            // Cannot use `std::thread::sleep` because it blocks the Tokio runtime.
            time::sleep(scheduler.time_till_next_job()).await;
        }
    }));

But it does not work as expected.

Also see ntex-rs/ntex#335 (comment)

@photino photino added enhancement New feature or request bonus We can offer a bonus for someone who fix this issue. labels Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bonus We can offer a bonus for someone who fix this issue. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant